[Zope] Cacheing

Jason Jones jason_j@countermedia.org
Tue, 14 Sep 1999 14:23:52 -0500


> :These might be dumb questions, but like I said I don't know that much
about
> :squid. I understand that it is a proxy server, but it doesn't have any
zope
> :integration does it?
>
> you could set a cache control header to  "must-revalidate".
>
> a caching proxy then would check back with an "If-Modified-Since"
> request to see if the object was modified since the last request.
>
> zope / apache would have to provide "Last-Modified" headers in
> order to make this work.
>
> <- snip ->

Thanks for the info, it was a good read. Unfortunately the cache_docs you
mention state that the best way to cache dynamic content is to dump it to a
static file. That's exactly what I'm trying to avoid. The second suggestion
is to set an age related header. For the most part this will work well
enough for me, but it's not an ideal solution. I really would like the
if-Modified-since type of thing, but for that I would need to generate the
validators and then test from zope when a request comes in and respond
appropriately, which would mean dtml executing for each validation (I
assume).

I still think the best thing is some sort of cache between the webserver and
zope that gets updated automatically on a zope object change. For instance,
cacheable objects should cache themselves, just like ZClasses can catalog
themselves, but the cache shouldn't be ZODB based. That way I could select
files to cache, not worry about arbitrary modification times, not worry
about generating static files and not worry about the ZODB slowing things
down. Instead I could serve up pre-generated pages from memory like static
pages, directly from apache or zserver or whatever (zope would have to be
modified appropriately to check the cache first of course).

It seems like having an object in a ZCache object could render that to a
global dictionary with the url part as the key. Zope could then check the
dictionary and if the key exists, send it out. If the page changes, then it
gets recached and the dictionary updated. If the url isn't in the
dictionary, then zope runs normally. This could be combined with standard
expires type cacheing to work pretty well. Internally, zope could check the
dictionary for cached object items (by url reference) when building pages
that can't be fully cached, so that at least some parts of the page are
cached.

for instance:

http://myserver/index.html could be fully cached,
http://myserver/members/index.html could be partly cached -
      (the dtml document at http://myserver/members/content might be cached
       while the method http://myserver/members/authenticate isn't,
       and both are glued into the index.html files)
and the pages like http://myserver/search/results could be cached based on a
expires time, so that ZCatalog returned stuff that might change every minute
or so could be cacheable


Jason