[Zope] Re: No-cache

Joe Goldthwaite joe at goldthwaites.com
Thu Jul 29 13:04:46 EDT 2004


Woooo Hooooo!  Thank you Casey!  That worked!

Well, it worked on IE6 but since that's what most of the people here are
using, I can live with it.  I use Firefox and it's still not working there.
I can play with that later.

It's funny.  I just installed some Firefox extensions last night. One of
them let's me display the page response headers.  That helped me make sure I
was setting them correctly.  I must be living a charmed life.

Thanks again for your help.


-----Original Message-----
From: zope-bounces at zope.org [mailto:zope-bounces at zope.org]On Behalf Of
Casey Duncan
Sent: Wednesday, July 28, 2004 7:18 AM
To: zope at zope.org
Subject: [Zope] Re: No-cache


On Tue, 27 Jul 2004 18:18:08 -0700
"Joe Goldthwaite" <joe at goldthwaites.com> wrote:

> Hello everyone,
>
> I've been trying to get a new navigation system working that uses
> cookies to change what data is viewed. Because of the way the system
> works, I want to force a page refresh every time a page is displayed.
> If the user presses the back button, I want to refresh the page.  If I
> use JavaScript to go back two pages, I want the pages refreshed.
>
> This seems like a pretty simple thing to do. All you need to do is
> disable the caching of the pages. There's a lot of information on the
> web about it. The only problem is, I can't get anything to work.
>
> So far, I've tried putting some meta tags in the head statement.  I've
> various combinations of;
>
> <meta http-equiv="expires" content="-1">
> <meta http-equiv="expires" content="0"
> <meta http-equiv="expires" content="Wed, 26 Feb 1997 08:21:57 GMT">
> <meta http-equiv="Pragma" content="no-cache">
> <meta http-equiv="Cache-Control" content="no-cache">
> <meta http-equiv="Cache-Control" content="no-store">
>
> No combination of the above have worked on either Firebird or IE6.

Usually setting HTTP headers is more effective then meta tags. When
writing concurrent database apps TTW, you often want intermediate result
pages to remain uncached so that the execute a server query everytime
the page is viewed, including redirects or pressing the back button.
Setting expires and pragma: no-cache is the traditional way to do this,
but I would suggest trying it by setting the headers in Zope. The
following python script would do this:

## Script (Python) "dont_cache"
##title=Prevent browser from caching this response
setHeader = context.REQUEST.RESPONSE.setHeader
setHeader('Pragma', 'no-cache')
setHeader('Expires', '0')

Then call this script from a template you don't want the browser to
cache:

<html>
  <body tal:define="x here/dont_cache">
    ..
  </body>
</html>

If that doesn't work you might also try setting the "Last-Modified"
header to the current date and time. Setting "Cache-Control" maybe good
as well just to drive the point home.

hth,

-Casey



_______________________________________________
Zope maillist  -  Zope at zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists -
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )



More information about the Zope mailing list