Forums / Setup & design / Expires and Cache-Control configuration

Expires and Cache-Control configuration

Author Message

Pascal France

Tuesday 10 March 2009 8:43:43 am

Hi,

I'm trying to set Cache-Control header to my web pages.

First I've read these topics:

http://ez.no/developer/forum/setup_design/setup_httpheadersettings
http://ez.no/developer/forum/setup_design/httpheadersettings_content_type_application_xhtml_xml

and the comments in [HTTPHeaderSettings] in site.ini.

The form of my URI is: http://mysite.com/xxx/mypage (without .html at the end)

I use a virtualHost as describe in this doc:
http://ez.no/doc/ez_publish/technical_manual/3_8/installation/virtual_host_setup

For now, I can configure Cache-Control for images, javascripts, css, etc ... but not at all for pages with MIME «text/html»

In httpd.conf (Apache 1.3.41 - eZP 3.10.1) I have:

<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/gif "access plus 30 days"
ExpiresByType image/jpg "access plus 30 days"
ExpiresByType image/jpeg "access plus 30 days"
ExpiresByType image/png "access plus 30 days"
ExpiresByType image/x-icon "access plus 30 days"
ExpiresByType text/html "access plus 2 days"
ExpiresDefault "access plus 40 days"
</IfModule>

But the line:
ExpiresByType text/html "access plus 2 days"
has no effect. I always get:

GET /eZ-publish HTTP/1.1
...
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
If-Modified-Since: Tue, 10 Mar 2009 14:48:00 GMT

HTTP/1.x 200 OK
Date: Tue, 10 Mar 2009 14:48:40 GMT
Server: Apache/1.3.41 (Unix)
Expires: Tue, 10 Mar 2009 12:48:40 GMT
Cache-Control: no-cache, must-revalidate
Pragma: no-cache
Last-Modified: Tue, 10 Mar 2009 14:48:40 GMT
...

I've tried many other MIME types but without success

So I've set HTTPHeaderSettings in override/site.ini.append.php like this:

[HTTPHeaderSettings]
CustomHeader=enabled
HeaderList[]
HeaderList[]=Cache-Control
HeaderList[]=Pragma
HeaderList[]=Expires

Cache-Control[]
Cache-Control[/]=10000;2;5

But this doesn't product any result.

Thanks for your help.

Pascal

Ce qui embellit le désert c'est qu'il cache un puits... quelque part... (A. de Saint-Exupéry) - http://luxpopuli.fr/eZ-Publish

Pascal France

Tuesday 10 March 2009 11:12:44 am

Hi,

As I can't set the Cache-Control header for the html document, I've changed the index.php file like this:

 470 // send header information
 471 $headerList = array( 'Expires' => 'Mon, 26 Jul 1997 05:00:00 GMT',
 472                      'Last-Modified' => gmdate( 'D, d M Y H:i:s' ) . ' GMT',
 473                      'Cache-Control' => 'max-age=1800',
 474                      'Pragma' => ' ',

Now, the answer of the server looks like this:

HTTP/1.x 200 OK
Date: Tue, 10 Mar 2009 17:33:00 GMT
...
Expires: Wed, 22 Jun 2011 01:33:00 GMT
Cache-Control: max-age=1800
Last-Modified: Tue, 10 Mar 2009 17:33:00 GMT
...

...and there is a copy of the html document in the cache of Firefox (I can edit it).

But each time I reload the page, Firefox downlaod the document on the server (statut code 200 OK) and never use the copy in its cache.

Is there really a way to cache the HTML document?

Pascal

Ce qui embellit le désert c'est qu'il cache un puits... quelque part... (A. de Saint-Exupéry) - http://luxpopuli.fr/eZ-Publish