[Zope-CMF] CachingPolicyManager improvements

Geoff Davis geoff at phds.org
Fri Sep 2 16:31:26 EDT 2005


Hi all--

I have added some useful new functionality to CMFCore's
CachingPolicyManager:

1) Caching policies can now control all the Cache-Control tokens defined
in the HTTP 1.1 spec (s-maxage, public, private, no-transform).  To
implement this, I have added some extra keyword arguments to the API;
existing calls should not break, though.

2) When you enable no-cache, a Pragma: no-cache header is also sent for
HTTP 1.0 clients

3) FSPageTemplates have the option to return a status 304 + no content
when a conditional GET is sent.  This is a potential significant win for
sites. 

How it works: When a client has an expired page in its local cache, it
sends a conditional GET to the server.  Basically that means that there
will be an If-Modified-Since header with the timestamp of the local cached
page and, if the cached page was originally sent with an ETag, an
If-None-Match header with the ETag of the cached page (actually a list of
ETags of cached pages).

If an FSPageTemplate is associated with a Caching Policy and that Caching
Policy has 304s explicitly enabled, a series of checks take place.  If
there is an If-Modified-Since header, the server checks the modification
time associated with the template via the Caching Policy.  If there is an
If-None-Match header and the Caching Policy defines an ETag function, the
ETag is checked.  If all the checks pass, the server returns a 304 status
and stops without rendering the page.  The server does less computation,
and less data goes over the wire, so it's a double win.

I have written unit tests for all the new functionality including what I
believe to be the first CMFCore test suite to use ZopeTestCase. 
ZopeTestCase provides a lot of useful functionality, including
functional tests, that I think will make for easier test writing going
forward.

Is there anything I need to do before checking it in?

Geoff





More information about the Zope-CMF mailing list