[Zope] Re: Caching zope pages

Andrew Sawyers andrew at zope.com
Tue Dec 14 11:25:22 EST 2004


John Poltorak wrote:
> On Tue, Dec 14, 2004 at 10:13:37AM -0500, Andrew Sawyers wrote:
> 
>>John Poltorak wrote:
>>
>>>On Mon, Dec 13, 2004 at 06:32:55PM -0500, Tres Seaver wrote:
>>>
>>>
>>>>John Poltorak wrote:
>>>>
>>>>
>>>>
>>>>>This is something completely new to me... Do I install a CMP for each site 
>>>>>I host or can I have a global policy for the Zope instance?
>>>>
>>>>You may do either.  CMF skin methods will acquire 
>>>>'caching_policy_manager', if they can, from any parent (but only from 
>>>>the "nearest" one above them).
>>>
>>>
>>>How can I see the effects of the caching policy manager? Does it create 
>>>new headers? I've added a CPM but can't tell if it is doing anything.
>>>
>>> 
>>>
>>>
>>>>Tres.
>>>>-- 
>>>>===============================================================
>>>>Tres Seaver                                tseaver at zope.com
>>>>Zope Corporation      "Zope Dealers"       http://www.zope.com
>>>
>>>
>>>
>>What policy did you add?
> 
> 
> In the root folder I have:-
> 
> Policy ID      policy1
> Predicate      python:1
> Mod.Time       content/modified
> Max age (secs) 300
> 
> some of these values were defaults. 
> 
> 
>>If you followed my example, look for the cache-control header.
>>
>>Use wget -S url
> 
> 
> 
> wget -S http://localhost/ returns:-
> 
> --15:22:01--  http://localhost/
>            => `index.html.1'
> Resolving localhost... done.
> Connecting to localhost[127.0.0.1]:80... connected.
> HTTP request sent, awaiting response...
>  1 HTTP/1.0 200 OK
>  2 Server: Zope/(Zope 2.7.3-0, python 2.3.4, os2emx) ZServer/1.1 Plone/2.0.5
>  3 Date: Tue, 14 Dec 2004 15:22:02 GMT
>  4 Content-Length: 3053
>  5 Content-Type: text/html
>  6 X-Cache: MISS from localhost
>  7 X-Cache-Lookup: HIT from localhost:80
>  8 Connection: keep-alive
> 
> 
> Not sure if this includes the cache-control header you are referring to...
> 
> Should squidclient return something similar?
> 
>  
> 
>>Andrew
>>
>>-- 
>>Zope Managed Hosting
>>Systems Administrator/Software Engineer
>>Zope Corporation
>>(540) 361-1700
> 
> 
> 
So, the cache header has not gotten in.  Are you using a file system 
skin to render the site?  I see it's Plone/2.0.5 -- I know 0 about Plone.

So, test this:  Add a python script to your site's main_template, 
something like:
<div tal:define="cache_header here/cache_header"/> where cache_header is 
a python script:

Create a python script in the root of your site: cache_header.py

context.REQUEST.RESPONSE.setHeader('Cache-Control','max-age=30, 
must-revalidate')

Then you should see the caching headers in your Zope responses and the 
pages be cached in your Squid.  Note, unless you want every page cached 
with a max-age=value as the above python script would do - this is not 
the *right* method.  I'm just trying to help you get rolling.  If all 
requests can be cached for a specific amount of time - then you can 
accomplish this completely in squid and not require the Zope server to 
set any headers.

What is your cache strategy?  I'm just guessing, but I'd thought you 
were just getting rolling and learning.  While this isn't really hard - 
it's not "free" and will take some thought, design, and setup if it's 
not a simple cache policy you're after.


Andrew

-- 
Zope Managed Hosting
Systems Administrator/Software Engineer
Zope Corporation
(540) 361-1700


More information about the Zope mailing list