Rewrite rules for static cache

Rewrite rules for static cache

Monday 15 October 2007 6:31:08 am - 4 replies

Author Message

Cemil Giray

Tuesday 06 November 2007 2:09:04 am

Hi. Anyone have any solutions for this one?

Messages must cause change.

Stefan de Bruijn

Tuesday 06 November 2007 8:33:56 am

Have you checked what exactly is generated in /static/site1 and static/site2?

the url http://mysite.com/index.php/site1 would translate to:
/home/www/static/index.php/site1/index.html
So first loose the 'index.php'.

I never use static cache for multiple siteaccess in one Ez Publish installation (easier to make multiple installations).
IF it's going to work: you have to have the siteaccess name in your url. ( like http://mysite.com/site1 and http://mysite.com/site2)

According to the instructions :
"You should only add rewrite rules for the VHOSTs for which you want to have static caching. <i>In reality, this means that for each siteaccess that you want to cache, you need a different VHOST block in the Apache configuration.</i>"

I use different rewrite rules (works for 1 siteaccess, could work if you have the siteaccess name in your url, and the /static/site1 and /static/site2 are correctly generated). Example:

RewriteEngine On
# static cache in ez
# no cache for http posts
RewriteCond   %{REQUEST_METHOD} !^POST$
# do not cache vhost admin
RewriteCond   %{HTTP_HOST} !^admin.*$
# non caching vhost for passing the static cache
RewriteCond   %{HTTP_HOST} !^nocache\.mydomain\.nl$
# Does the index.html exist in the static cache?
RewriteCond   /srv/www/dbcc/static$1/index.html -f
#rewrite to the static cache
RewriteRule   ^(.*)$  /static$1/index.html [L]

#default ez rewrites
Rewriterule ^/var/storage/.* - [L]
Rewriterule ^/var/[^/]+/storage/.* - [L]
RewriteRule ^/var/cache/texttoimage/.* - [L]
RewriteRule ^/var/[^/]+/cache/texttoimage/.* - [L]
Rewriterule ^/design/[^/]+/(stylesheets|images|javascript)/.* - [L]
Rewriterule ^/share/icons/.* - [L]
Rewriterule ^/extension/[^/]+/design/[^/]+/(stylesheets|images|javascripts?)/.* - [L]
Rewriterule ^/packages/styles/.+/(stylesheets|images|javascript)/[^/]+/.* - [L]
RewriteRule .* /index.php

If it works, you still have to make a page for 'http://mysite.com/' (or point it to one of the 2 siteaccess). you could use:

# rewrite homepage only
# check for index.html
RewriteCond   $1 =/ [OR]
RewriteCond   $1 =""
RewriteCond   /srv/www/dbcc/static/index.html -f 
RewriteRule   ^(.*)$  /static/index.html [L]
#no index.html
RewriteCond   $1 =/ [OR]
RewriteCond   $1 =""
RewriteRule   ^(.*)$  /index.php [L]

You could make a page for letting the visitor choose the siteaccess and point your homepage there

..
RewriteCond   /srv/www/dbcc/static/site1/choose/index.html -f 
RewriteRule   ^(.*)$  /static/site1/choose/index.html [L]
..
RewriteRule   ^(.*)$  /site1/choose/index.php [L]

Stefan de Bruijn

Tuesday 06 November 2007 8:53:08 am

I didn't read the complete instructions on http://ez.no/developer/articles/ez_publish_performance_optimization_part_3_of_3_practical_cache_and_template_solutions/static_cache. There are also instructions on using the cache with multiple site-accesses.

But as far as I understand the rewrite rules (http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html) for the given example don't work:

RewriteCond /home/httpd/ez-3.6/static/news_en/index.html -f
RewriteRule ^/$            /static/news_en/index.html [L]
RewriteCond /home/httpd/ez-3.6/static/news_en/index.html -f
RewriteRule ^$             /static/news_en/index.html [L]

RewriteCond /home/httpd/ez-3.6/static/news_fr/index.html -f
RewriteRule ^/$            /static/news_fr/index.html [L]
RewriteCond /home/httpd/ez-3.6/static/news_fr/index.html -f
RewriteRule ^$             /static/news_fr/index.html [L]

If "RewriteCond /home/httpd/ez-3.6/static/news_en/index.html -f" is true, then the root-url ('mydomain.com/) is rewritten to mydomain/static/news_en/index.html and no further rewrites are done. The french siteaccess will only be used if there is no english static cache?!

Fabrice Girardot

Tuesday 06 November 2007 9:07:30 am

Hi Stefan, thank you very much for your post.

This is the real urls (for a test siteaccess called "wac_test" right now, but all the other static are already done for en/fr/es/pt/ru) :

the dynamic: http://www.worldaidscampaign.info/index.php/wac_test/
and the static: http://www.worldaidscampaign.info/static/wac_test/

The problem is all the links in the static always referred to the dynamic part, so we need to rewrite every "/index.php/wac_test" with "/static/wac_test" (let's keep the other siteaccess dynamic). I have really no idea how I can do this.

--
Fabrice

You must be logged in to post messages in this topic!

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.