0

all

I know that this question has been answered a zillion times but I am having problems that I thought were solved. I have a localhost test site (gae) it all runs fine except the pages are being cached even though I have explicitly set the python headers to not cache.

self.response.headers["Cache-Control"] = "no-cache, no-store, must-revalidate, pre-check=0, post-check=0"
self.response.headers["Expires"] = "Thu, 01 Dec 1994 16:00:00"
self.response.headers["last-modified"] = "Thu, 01 Dec 2000 16:00:00"
self.response.headers['Cache-Control'] = 'private, max-age=0'
self.response.headers["Pragma"] = "no-cache"

I am calling Handlers via various ways, for example: window.location.href = "/test-page", and everything thing works great and here is the response header in firebug:

Cache-Control   private, max-age=0
Content-Length  26070
Content-Type    text/html; charset=utf-8
Date    Sun, 10 Aug 2014 18:39:29 GMT
Expires Thu, 01 Dec 1994 16:00:00
Last-Modified   Thu, 01 Dec 2000 16:00:00
Pragma  no-cache
Server  Development/2.0
Set-Cookie  hl=en_US; Max-Age=157680000; Path=/; expires=Fri, 09-Aug-2019 18:39:29 GMT     dvc=desktop; expires=Sun, 24-Aug-2014 18:39:29 GMT; path=/; HttpOnly session_name="eyJfdXNlciI6WzU2Mjk0OTk1MzQyMTMxMjAsMCwieHZITk5rbGpoSjVMOWllNFRVNVNHOSIsMTQwNzY5NTk1MiwxNDA3Njk1OTUyXX0\075|1407695969|433299a97d00e1d09a1f9670c17c5fb56524a214"; Path=/
x-ua-compatible IE=Edge,chrome=1

I just can't figure this out. Any help would be much appreciated, thanks.

p.s. The bfcache is the culprit but why is it not following the rules of the headers?

Chez
  • 961
  • 1
  • 9
  • 20
  • 1
    I don't understand what you are asking. The headers show exactly what you set. What makes you think the pages are "caching"? – Daniel Roseman Aug 10 '14 at 19:01
  • Hi, Daniel, well if I am not mistaken, when you hit the back button the page should be re-loaded no? Mine are not there are no requests being made... – Chez Aug 10 '14 at 19:12
  • As Greg says, you are mistaken. The back button does not re-request the page, and the back/forward cache is completely separate from the usual caching mechanisms. – Daniel Roseman Aug 10 '14 at 19:17
  • Ok, thanks, but I'm confused. So how do I prevent an authenticated user page from being seen after a logout for example? Given tht I want to allow the bfcache to function whilst user is logged in. – Chez Aug 10 '14 at 19:28
  • Ok, I think I've got this... after reading the docs at Mozilla using the window.onpageshow and reloading is one way to force reloading of a page. – Chez Aug 10 '14 at 19:49
  • Daniel, out of interest, regarding your first comment, is a page not cached if it is in bfcache? If not then what is it then? Perhaps more importantly, why is the bfcache separate from normal caching, if I wanted my page to be cached I wouldn't bother with the response headers to prevent it. In my opinion the bfcache is a royal pain in the toots – Chez Aug 10 '14 at 20:02

0 Answers0