No matter what, I can't get Static Cache to work.

Author Message

Massimiliano Bariola

Friday 14 October 2005 7:08:48 am

Hi, using eZ 3.7.0 here.

I have been whacking my head all day to make static cache work, with discouraging results.

I followed to the letter all the instructions and info at the following urls...

http://ez.no/download/changelogs/ez_publish_3_6/new_features/static_caching_of_content

http://ez.no/community/forum/developer/staticcache_makestaticcache_php_and_siteaccess

http://ez.no/community/forum/install_configuration/3_6_static_cache_for_siteaccesses

http://ez.no/community/forum/install_configuration/static_cache_publishing_doesn_t_update_static_cache

and many others I have found on the site, to no avail.

I have 2 siteaccesses, one for public view, with no login-protected areas whatsoever, and a default admin siteaccess. I want all the pages from the user siteaccess to be statically cached, and none from the admin siteaccess.

After lots of changes and copying / moving staticcache.ini.append.php back and forth between the override dir and the public siteaccess dir, the closest I have gotten to have the static cache work, is for the script to generate the static cache for the public home page. But then, it uses the same home page both for the public site and for the admin site, effectively blocking me from entering the admin site. I am using the "only one siteaccess" aprt of the steps as, in fact, I am only interested in caching the public site.

with the current settings -- which I think should be the correct ones for my case -- cache is not generated at all :

override/staticcache.ini.append.php :

[CacheSettings]
HostName=localhost
StaticStorageDir=static
MaxCacheDepth=4

# A list of url's to cache. You can use the * wildcard to include a whole
# subtree.
CachedURLArray[]
CachedURLArray[]=/*

# A list of site accesses to generate static content for
CachedSiteAccesses[]=corporate_user

# A list of locations that will be updated whenever an object is published. You
# can NOT use a wildcard here.
AlwaysUpdateArray[]
AlwaysUpdateArray[]=/

corporate_user/site.ini.append.php:

[ContentSettings]
TranslationList=
#ViewCaching=disabled
#StaticCache=disabled
ViewCaching=enabled
StaticCache=enabled

I am calling the makestaticcache.php from CLI like this:

bin/php/makestaticcache.php -s corporate_user

and I get as output the list of nodes of which I suppose it's generating the cache.

unfortunately, the static dir is empty. it has correct permissions to be written, and indeed it has been written to when following Lukas 's advice found here ... http://ez.no/community/forum/install_configuration/static_cache_publishing_doesn_t_update_static_cache

but that caused also the admin site being cached and the reachability problem I found.

Anyone can help me out ?? I have no clues.

thanks

Łukasz Serwatka

Monday 17 October 2005 12:52:50 am

Which site access method do you use? URI or Host? If Host you can try with empty array of CachedSiteAccesses but you will need 2 virtual hosts setup, one for public view and one for admin.

CachedSiteAccesses[]

If you use URI try like this:

CachedSiteAccesses[]
CachedSiteAccesses[]=corporate_user

Personal website -> http://serwatka.net
Blog (about eZ Publish) -> http://serwatka.net/blog

Massimiliano Bariola

Monday 17 October 2005 1:51:45 am

Hi Lukasz,

I use an host-based setup and yes, I have 2 siteaccesses, one for users (corporate_user) and one for admin (corporate_admin).

where do I have to put the lines you suggest? (override or siteaccess site.ini?) won't an empty CachedSiteAccesses result in an undesired caching of the admin site as well?

Łukasz Serwatka

Monday 17 October 2005 1:57:44 am

Then you will need two VH configs one for user site and one for admin site and CachedSiteAccesses[] should be empty, without siteaccess name. Put it in to staticcache.ini.append.php in override dir. VH will point to the same IP address but for admin will be different ServerName admin.yoursite.com and without part of re-write rule for static cache.

Personal website -> http://serwatka.net
Blog (about eZ Publish) -> http://serwatka.net/blog

Massimiliano Bariola

Monday 17 October 2005 3:41:02 am

Hi Lukasz

Not working yet .. I did as you told me and created the 2 VHs which I submit below. I think I also found a couple bugs. maybe not.

FRONT VH (to be statically cached):


    DocumentRoot /usr/local/apache/htdocs/ezpublish-3.7.0/
    ServerName front.prodigiweb.it

...........

  <IfModule mod_rewrite.c>
        RewriteEngine On
        RewriteLog /var/log/httpd/prod_logs/prod3.7.0.rewrite_log
        RewriteLogLevel 2
        # eZ publish >= 3.4.x :
        RewriteCond   /usr/local/apache/htdocs/ezpublish-3.7.0/static/index.html -f
        RewriteRule  ^/$              /static/index.html [L]
        RewriteCond   /usr/local/apache/htdocs/ezpublish-3.7.0/static/index.html -f
        RewriteRule  ^$               /static/index.html [L]

        RewriteCond   %{REQUEST_METHOD}       !^POST$
        RewriteCond   /usr/local/apache/htdocs/ezpublish-3.7.0/static$1/index.html -f
        RewriteRule   ^(.*)$  /static$1/index.html [L]
        RewriteRule !(^/design|^/var/.*/storage|^/var/storage|^/var/.*/cache|^/var/cache|^/extension/.*/design|^/kernel/setup/packages|^/packages|^/share/icons).*\.(gif|css|jpg|png|jar|js|ico|pdf|swf)$ /index.php
    </IfModule>
..........

ADMIN VH (NOT to be statically cached):

    DocumentRoot /usr/local/apache/htdocs/ezpublish-3.7.0/
    ServerName beta.prodigiweb.it
    
    ...................
  ## I suppose that last rewrite-rule is still needed , even if I don't have Static Caching, right?  
  <IfModule mod_rewrite.c>
        RewriteEngine On
        RewriteLog /var/log/httpd/prod/prod3.7.0.rewrite_log
        RewriteLogLevel 2
        RewriteRule !(^/design|^/var/.*/storage|^/var/storage|^/var/.*/cache|^/var/cache|^/extension/.*/design|^/kernel/setup/packages|^/packages|^/share/icons).*\.(gif|css|jpg|png|jar|js|ico|pdf|swf)$ /index.php
    </IfModule>
    .........

I was able to get the root page (corresponding to /) and node 2 of the frontend statically compiled by calling the makestaticcache.php script with -s corporate_user , with -f and without any parameters. but that's all. I submit the relevant parts of my config files:

override/staticcache.ini.append.php

[CacheSettings]
HostName=localhost
StaticStorageDir=static
MaxCacheDepth=4

# A list of url's to cache. You can use the * wildcard to include a whole
# subtree.
CachedURLArray[]
CachedURLArray[]=/*

# A list of site accesses to generate static content for
CachedSiteAccesses[]

# A list of locations that will be updated whenever an object is published. You
# can NOT use a wildcard here.
AlwaysUpdateArray[]
AlwaysUpdateArray[]=/

override/site.ini.append.php

MatchOrder=host
HostMatchType=map
HostMatchMapItems[]=front.prodigiweb.it;corporate_user
HostMatchMapItems[]=beta.prodigiweb.it;corporate_admin

[ContentSettings]
StaticCache=enabled

I noticed this output when running the makestaticcache.php with the above configuration:

  cache /users/administrator_users
  cache /users/administrator_users/alberto_muci
  cache /users/administrator_users/danilo
  cache /users/administrator_users/massimiliano_bari
  cache /users/administrator_users/utente_ammin
  cache /users/anonymous_users
  cache /users/anonymous_users/anonymous_user

This means that the script is caching, or at least scanning, my admin-side user nodes as well as my user-side content!! this is something I don't want. The script should recognize that those nodes are *not* to be scanned as they would never be accessed by an anonymous user - which is one of the tenets of static caching; only content accessible by anonymous users.

Another thing: when I activate the static cache, all my accented characters in the only generated page messed up. this does not happen with static caching deactivated. I have an italian page, charset for db and templates is utf-8.

Are they bugs which I have to report ? or did I do something wrong ?

Also, question:

In this site, I don't use the "full" templates for the nodes, but the "line" ones. there is no direct link to nodes, but only to the folders contaning the objects, which have a template which cycles and displays the "line" template of all the contained nodes. can this affect the working of the static cache? From the output of the makestaticcache.php file, the urls corresponding to the folder are scanned, so the static pages should be generated correctly.

As you see, lots of things to ask and clarify. Please take the time to look into them in depth, I think it would be useful to other static-cachers around.

Łukasz Serwatka

Monday 17 October 2005 4:51:43 am

Massimiliano, in your staticcache.ini.append.php file you have set HostName to localhost. This is wrong, it should point to your front.prodigiweb.it, HostName is used ( http://front.prodigiweb.it ) as parameter of file_get_contents php function in kernel/classes/ezstaticcache.php

Personal website -> http://serwatka.net
Blog (about eZ Publish) -> http://serwatka.net/blog

Massimiliano Bariola

Monday 17 October 2005 6:37:07 am

Lukasz,

I tried as you said, and it finally worked. But I had to use front.prodigiweb.it , and not http://www.prodigiweb.it. I think that the following page needs to be corrected
http://ez.no/doc/ez_publish/technical_manual/3_6/reference/configuration_files/staticcache_ini/cachesettings/hostname

I will make a comment there.

About the script scanning the users/ directory: Now that I see that the script is working, I see that it actually scans the users/ directory and generates the static pages just as if an anonymous users would have seen them. phew!

But I still see that it generates pages with the wrong set of characters. this happens only in static pages, while the normally-generated pages do not exhibit that behavior. So, at the moment, I cannot use the static cache until the solution is found. any ideas of where to look?

Bye

Massimiliano Bariola

Monday 17 October 2005 7:14:08 am

ops I wanted to say : "I used front.prodigiweb.it and not http://front.prodigiweb.it"

Łukasz Serwatka

Monday 17 October 2005 11:12:43 pm

Try to put in first line of pagelayout code:

{*?template charset=utf-8?*}

Then clear all cache and regenerate static cache.

Personal website -> http://serwatka.net
Blog (about eZ Publish) -> http://serwatka.net/blog

Massimiliano Bariola

Tuesday 18 October 2005 3:18:25 am

Hi Lukasz,

I tried but to no avail.

The funny thing is that wget'ing the file, it has an header specifying utf-8 in both cases - pages with static caching on and off. but with static caching, the accented characters are broken.

I found a similar problem with eZ publish in an earlier project. when accessing data through eZpublish , the characters were seen ok. when accessing data via my extension and sql queries, the data would not be displayed correctly.

I discovered that the problem was due to the mysql client opening a connection using a latin_1 charset. the only way to have it work correctly was to make an additional sql query like this:

$db->query('SET CHARACTER SET utf8;');

maybe this is due to the fact that the makestaticcache.php uses a different way of interfacing to the database so it makes different assumptions? i.e. sets up the connection differently?

I know that my db_client should stick to utf-8 ... :-) but the fact that normal eZ pages behave correctly and the script cache does not, hints me that maybe this is the problem here; a different behavior of connection to DB.

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