[Zope] Re: No-cache
Casey Duncan
casey at zope.com
Wed Jul 28 10:18:27 EDT 2004
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
More information about the Zope
mailing list