Personal tools
You are here: Home Documentation How-tos Cache Content
Support

Get Help

Join our chat rooms or support forums if you have more specific questions.

Plone Training
Learn how to design, build, and deploy a website in Plone through one of the numerous Plone training sessions around the world.
Find Plone training…
 
Document Actions

Cache Content

Warning: This item is marked as outdated.

This How-to applies to: Plone 2.1.x, Plone 2.0.x
This How-to is intended for: Server Administrators

How to change Plone's default cache settings so you can cache pages on your site.

Caching Overview

Andy McKay gave an excellent presentation on this topic at the first Plone conference. Read his presentation notes

Some other resources worth reading:

Plone Modifications

Plone's default cache settings do not cache pages. Use the following information to change the settings and let your site cache pages. You need to modify the global_cache_settings file in the plone_templates directory:

  <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,Accept-Encoding,User-Agent,Cookie')" />

  <metal:block tal:define="dummy python:request.RESPONSE.setHeader('Pragma', 'no-cache')" />

  <metal:block tal:define="dummy python:request.RESPONSE.setHeader('Connection', 'keep-alive')" />

  <metal:block tal:define="dummy python:request.RESPONSE.setHeader('Last-Modified', 'here.modified().toZone('GMT').rfc822())" />

Explanation of code above

Vary setting
tells upstream caches to cache by language, encoding, browser and cookie. Note that Internet Explorer requires a page in different languages to have a distinct url for each language, even when language value is different here.
Pragma : no-cache setting
tells browsers to not cache the content. The content should be cached only by Apache, Squid or some other cache on the server, for optimal cache control.
Connection : keep-alive setting
allows persistent connections which can speedup latency times for HTML documents with lots of images.
LastModified header
reports the actual last modified time of the object to an upstream cache, which makes sense for caching.

Zope Modifications

If you are going to use one or more HTTP Accelerated Cache Managers, you need to fix a bug in Zope's AcceleratedHTTPCacheManager.py file. Uncomment the following line:

    RESPONSE.setHeader('Last-Modified',rfc1123_date(time.time()))

This will ensure that Zope returns a valid Last-Modified HTTP header. Without it, caches will assume that your content has been dynamically generated and is not suitable for caching.

by gerrykirk — last modified March 29, 2006 - 10:52 All content is copyright Plone Foundation and the individual contributors.

doc sprint review

Posted by JoAnna Springsteen at February 6, 2006 - 01:42

Consider revising so that this how to is more procedural. Use numbers to indicate each step. This how to also seems to assume some prerequisite knowledge. Is that what the external links are for? If so, please indicate that the user should read (and know?) X,Y, and Z first before completing this procedure.

Suggested global_cache_settings broke Content_Type encoding in Firefox/Mozilla and Safari

Posted by Fred van Dijk at March 29, 2006 - 10:59

Those who copied the global_cache_settings from an earlier version of this document ended up with broken Content-Type header settings for Mozilla/Firefox and Safari users. The Content-Type was set to charset = %s. The spaces around the = are no problem for IE(6), but destroys utf-8 characterson these other browsers, like ä, î, é and friends.

Changed in the document.

This how-to breaks Plone

Posted by Jason Stubblefield at April 11, 2006 - 07:34

If you follow these instructions in Plone 2.1.2, it will break your plone instance. I would not do what this document reccommends. Now to reinstall...

stray apostrophe

Posted by Jason Stubblefield at April 13, 2006 - 15:49

This should work. You will have to make sure all your servers are set to use GMT. I also don't understand why the no-cache and keep-alive headers are included. I think it would be best to remove those lines, although I have left them in the code below. The Zope bug this article talks about has been fixed in the distribution that came with Plone 2.1.2 for SuSE Linux (2.7 ?).

How do I post code examples?

Posted by Jason Stubblefield at April 13, 2006 - 15:54

Plone.org didn't like my code example. Remove the apastrophe in front of here.modified in the last line of code.

It breaks localized user interface

Posted by Peter Pruchnerovic at May 24, 2006 - 11:10

I dont recommend using this for websites where localized user interface is used. It took me two weeks to find out where that fuc**ng problem was.


For any issues with the web site functionality, please file a ticket.

Please consult the policy on plone.org content if you want your content published on this site.

Servers and hosting by