eZ Community » Forums » Setup & design » Expires and Cache-Control configuration
expandshrink

Expires and Cache-Control configuration

Expires and Cache-Control configuration

Tuesday 10 March 2009 4:43:43 pm - 2 replies

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/setu...s_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/techn.../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

Modified on Tuesday 10 March 2009 4:44:54 pm by Pascal France

Tuesday 10 March 2009 7:12:44 pm

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

Modified on Tuesday 10 March 2009 7:14:17 pm by Pascal France

Monday 05 August 2013 5:52:10 pm

You should add

 

[HTTPHeaderSettings]
Expires[]
Expires[/]=7200
expandshrink

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

36 542 Users on board!

Forums menu

Proudly Developed with from