Cache Content- Anonymous only
go to the ZMI portal_skins/plone_templates/global_cache_settings, click customize.
change the content to:
<metal:cacheheaders define-macro="cacheheaders">
<metal:block tal:define="dummy python:request.RESPONSE.setHeader('Content-Type','text/html;;charset=%s' % charset)" />
<metal:block tal:define="dummy python:request.RESPONSE.setHeader('Content-Language', lang)" />
<metal:block tal:define="dummy python:request.RESPONSE.setHeader('Vary','Accept-Language,Cookie,Accept-Encoding')" />
<metal:block tal:define="dummy python:request.RESPONSE.setHeader('Last-Modified', here.modified().toZone('GMT').rfc822())" />
<metal:block tal:content="structure python:here.enableHTTPCompression(request=request, debug=0)" />
<tal:block condition="isAnon">
<metal:block tal:define="dummy python:request.RESPONSE.setHeader('Cache-control','max-age=3600,s-maxage=3600')" />
</tal:block>
<tal:block condition="not:isAnon">
<metal:block tal:define="dummy python:request.RESPONSE.setHeader('Cache-control','Must-revalidate,max-age=0,no-cache')" />
<metal:block tal:define="dummy python:request.RESPONSE.setHeader('Pragma','no-cache')" />
</tal:block>
</metal:cacheheaders>
all content will be cache for a hour for anonymous user
if you want to extend the time you can use apache, I enabled the expires_module (on the non-ssl conection only):
LoadModule expires_module modules/mod_expires.so
and set the virtualhost as follow:
ExpiresActive On
ExpiresDefault "access plus 1 hour"
ExpiresByType image/gif "access plus 1 week"
ExpiresByType image/jpeg "access plus 1 week"
ExpiresByType text/css "access plus 1 day"
ExpiresByType application/x-javascript "access plus 1 week"
Gotchas
If I went to http://hostname/ and saw a cached page and then logged in and went to http://hostname/ - I would be logged in but would still see a cached page, or it would kill the cache and the next anonymous visit would not get a cached page. This should be used in conjunction with separate host names:
- http://hostname/ for cached/anonymous content
- http://adminhostname/ for non-anonymous users
You also will want to change portal_caching_manager
