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. I was able to get a JavaScript routine that forced a refresh if a cookie was not present and then cleared the cookie out but it forced a double load on new pages. Some of the documentation I've been able to find mentions that the no-cache stuff only works with HTTP1.1 and that is controlled by the server. Most of the documentation I've been able to find on the subject is years old. My questions are; What version of HTTP does Zope use? Is there any way to change it? Is there some setting on the Zope server that I can use to turn off all caching? Anyone have any other idea why the above doesn't work? Thanks! Joe Goldthwaite
On Tuesday 27 July 2004 7:18 pm, Joe Goldthwaite 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.
Caching has nothing to do with the back button. You can tell it not to cache in any way you want but a properly written browser will ignore all of that for the back button. The back button is supposed to bring back whatever was on that page when it hit it just recently. Just like undo/redo operations. If your app design is based on hitting back and having the page refresh then your app design is broken and will not truly work. You might be able to put some hacks on a page with javascript that might cause it to reload but I don't know how you would really do it. Nothing about zope changes this since it is how browsers are supposed to work. Either make the app work when people hit the back button or tell them that using that will break things on the site and provide other ways to navigate so that the back button never needs to be pressed.
On Tue, 27 Jul 2004 18:18:08 -0700 "Joe Goldthwaite" <joe@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
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@zope.org [mailto:zope-bounces@zope.org]On Behalf Of Casey Duncan Sent: Wednesday, July 28, 2004 7:18 AM To: zope@zope.org Subject: [Zope] Re: No-cache On Tue, 27 Jul 2004 18:18:08 -0700 "Joe Goldthwaite" <joe@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@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 )
participants (3)
-
Casey Duncan -
Joe Goldthwaite -
kosh