I'm told to prevent user-info leaking, only "no-cache" in response is not enough. "no-store" is also necessary.
Cache-Control: no-cache, no-store
After reading this spec http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html, I'm still not quite sure why.
My current understanding is that it is just for intermediate cache server. Even if "no-cache" is in response, intermediate cache server can still save the content to non-volatile storage. The intermediate cache server will decide whether using the saved content for following request. However, if "no-store" is in the response, the intermediate cache sever is not supposed to store the content. So, it is safer.
Is there any other reason we need both "no-cache" and "no-store"?
For chrome, no-cache is used to reload the page on a re-visit, but it still caches it if you go back in history (back button). To reload the page for history-back as well, use no-store. IE needs must-revalidate to work in all occasions.
So just to be sure to avoid all bugs and misinterpretations I always use
if I want to make sure it reloads.
If you want to prevent all caching (e.g. force a reload when using the back button) you need:
no-cache for IE
no-store for Firefox
There's my information about this here:
http://blog.httpwatch.com/2008/10/15/two-important-differences-between-firefox-and-ie-caching/
Note that Internet Explorer from version 5 up to 8 will throw an error when trying to download a file served via https and the server sending
Cache-Control: no-cache
orPragma: no-cache
headers.See http://support.microsoft.com/kb/812935/en-us
The use of
Cache-Control: no-store
andPragma: private
seems to be the closest thing which still works.From the HTTP 1.1 specification:
I must clarify that
no-cache
does not mean do not cache. In fact, it means "revalidate with server" before using any cached response you may have, on every request.must-revalidate
, on the other hand, only needs to revalidate when the resource is considered stale.If the server says that the resource is still valid then the cache can respond with its representation, thus alleviating the need for the server to resend the entire resource.
no-store
is effectively the full do not cache directive and is intended to prevent storage of the representation in any form of cache whatsoever.I say whatsoever, but note this in the RFC 2616 HTTP spec:
But this is ommitted from the newer RFC 7234 HTTP spec in potentially an attempt to make
no-store
stronger, see:http://tools.ietf.org/html/rfc7234#section-5.2.1.5
Under certain circumstances, IE6 will still cache files even when
Cache-Control: no-cache
is in the response headers.The W3C states of
no-cache
:In my application, if you visited a page with the
no-cache
header, then logged out and then hit back in your browser, IE6 would still grab the page from the cache (without a new/validating request to the server). Adding in theno-store
header stopped it doing so. But if you take the W3C at their word, there's actually no way to control this behavior:General differences between browser history and the normal HTTP caching are described in a specific sub-section of the spec.