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

eZ debug

Timing: Jan 18 2025 11:34:48
Script start
Timing: Jan 18 2025 11:34:48
Module start 'content'
Timing: Jan 18 2025 11:34:49
Module end 'content'
Timing: Jan 18 2025 11:34:49
Script end

Main resources:

Total runtime0.9132 sec
Peak memory usage4,096.0000 KB
Database Queries189

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0068 588.9609180.8281
Module start 'content' 0.00680.7710 769.7891471.1641
Module end 'content' 0.77780.1353 1,240.9531333.7969
Script end 0.9131  1,574.7500 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00470.5164210.0002
Check MTime0.00180.2005210.0001
Mysql Total
Database connection0.00060.070310.0006
Mysqli_queries0.838891.85431890.0044
Looping result0.00210.23221870.0000
Template Total0.878696.220.4393
Template load0.00260.279920.0013
Template processing0.876095.924720.4380
Template load and register function0.00020.024810.0002
states
state_id_array0.00070.076010.0007
state_identifier_array0.00100.104320.0005
Override
Cache load0.00220.2423350.0001
Sytem overhead
Fetch class attribute can translate value0.00180.196820.0009
Fetch class attribute name0.00100.110720.0005
XML
Image XML parsing0.00040.038420.0002
class_abstraction
Instantiating content class attribute0.00000.000520.0000
General
dbfile0.00200.2189210.0001
String conversion0.00000.000530.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
2content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
9content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
3content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
5content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 21
 Number of unique templates used: 6

Time used to render debug report: 0.0002 secs