[Zope-dev] Etag support in page templates
Bjorn Stabell
bjorn at exoweb.net
Thu Sep 11 15:45:55 EDT 2003
Janko wrote:
> I think, this is one problem with the current code. There is
> no defined way to decide, when something is last modified.
> With CMF-based sites there is a clearly defined property for
> this. On the other hand all objects have at least a
> bobobase_modification_time, but this one changes with every
> ZODB action on the object.
>
> I'm not sure what to do.
Also, in most cases, the content of pages doesn't all come from one
object, so Last-Modfied doesn't really make sense since it should refer
to the whole page. I think the problem is with Apache's inability to
cache content with Expires set, and that Apache should be fixed.
ETAG NOTES
As for Zope, I'm not sure if setting and empty Etag header is the right
thing to do if no Etag was provided...?
I've been thinking about how Zope could be extended to support HTTP
validators on Etags. How about this (Page Templates = ZPT or DTML):
- Page Templates are extended with a customizable Etag function/
property. Could be part of the cachable interface. You should set this
to return a different etag if, and only if, the content of the page was
different.
- Page Templates are extended to support If-Match and other such
conditionals by calling the customized Etag function and returning 304
Not Modified if the Etag conditions are met (e.g., the calculated etag
is the same as the browser/cache provided etag).
- Upon rendering the top most Page Template the Etag is automatically
calculated and included in the HTTP Headers.
If all objects have an etag (Zope seems to be going in that direction
looking at the WebDAV code), then a simple way to calculate the etag for
a page would be the hash of all the etags for all of the content of that
page added together (string concats). Another way could be to let the
etag change every X seconds (to simulate the current expires caching
model).
Bye,
--
Bjorn
More information about the Zope-Dev
mailing list