Browser: Firefox 6.0
I've Page A with the following setup to make sure the content is NOT stored in the bfcache of the browser:
1) $(window).unload(function(){});
2) Following HTTP headers:
<meta http-equiv="pragma" content="no-cache" />
<meta http-equiv="expires" content="-1" />
<meta http-equiv="cache-control" content="no-cache"/>
I've also hooked up the events pagehide
and pageshow
. When I am navigating away from the page, pagehide
is invoked with CORRECT value for the event property persisted = false
(that is what needed: no persistence in cache!)
After navigating a couple of pages, I've a window.history.go(-2);
to go back to Page A. At this point, I want Firefox to poll the server for the updated version instead of displaying from the cache. The pageshow
of Page A is invoked with CORRECT value for the event propertypersisted = false
(meaning the page is NOT loaded from cache). BUT the page content is not the server data; it is the stale content (same as when navigating away from the page initially)! Fiddler also does not show a new request to server.
Google Chrome also exhibits the same behaviour. IE works as expected (reloads fresh data)!
Any idea what am i missing?
Thanks in advance!
There are multiple caches involved. There's the browser's document cache (bfache), the browser's HTTP cache, and possibly intermediate HTTP caches.
The <meta>
tags you show above have absolutely no effect in current Chrome or Firefox. They may have an effect in IE.
So chances are, your page is just being read from the browser's HTTP cache.
If you really want to send no-cache HTTP headers, you should do that. But they need to be actual HTTP headers: as I said above, the <meta>
tag "equivalents" do nothing.
And, importantly, any other intermediate caches are not going to be parsing your HTML so might cache things if you don't actually send the right HTTP headers.
Thanks! The following HTTP headers were already available:
Cache-Control: no-cache Pragma: no-cache Expires: -1
Unfortunately they didn't help either. After your reply, I revisited the headers and found that Firefox needs another header to prevent caching: blog.httpwatch.com/2008/10/15/…Cache-Control: no-cache, no-store
After adding the above header, it now works OK in IE, Firefox, Chrome & Safari. Only Opera still misbehaves by caching, but I am going to postpone that issue temporarily.Another note: Firefox does not store in bfcache if the site is SSL enabled! My production system is SSL whereas the DEV system is not. So the Production system works ok in Firefox WITHOUT any additional HTTP headers like the one mentioned above!
It depends on your HTTP headers. SSL + no-cache won't get stored in bfcache, but cacheable SSL will be.
Correct!
no-cache
header was already present in my case. By "additional HTTP header" I meant theno-store
header; which is not required if using SSL!