When the root page is subject to frequent invalidation, like a news feed, do you generally prefer no-store or no-cache in the response header of cache-control? One advantage of no-store - from what I can tell - is that it spares the browser from even making the pre-flight request to determine if local version is stale. Is no-store well supported?


The badly named no-cache doesn’t mean not to cache, but actually means “cache, but do not use without checking it’s still valid”. It is typically used for non-sensitive pages that will change often - like your example of a newspaper home page.

Whereas no-store means “don’t cache it at all”. It is typically used for sensitive pages (e.g. internet banking pages).

And finally the, also badly named, must revalidate max-age=XXXX means “use without revalidating this up until XXXX seconds have passed and then check with server before reusing it (i.e. treat it as no-cache)”. It is used for cacheable resources (whether for short times, long times or somewhere in between).

from what I can tell - is that [no-store] spares the browser from even making the pre-flight request to determine if local version is stale.

I think you’re misunderstanding this. It does make an additional pre-flight request. No-cache makes a request for the resource but also says “hey I have a version already let me know if that’s still valid”. If it’s still valid it gets a shorter response (304 Not Modified) if it’s not still valid it gets the full response back - just like it would with no-store. So there is no additional request, it’s just that no-cache might save you from re-downloading the whole resource again if it has not changed. Which is a good thing as it saves bandwidth for the client and the server. It’s pointless to re-download something of you already have it. Therefore you should always prefer no-cache over no-store for non-sensitive pages.

Is no-store well supported?

All of them are well supported by all browsers. Though it should be noted that browsers often will reuse the page on certain navigation, which can be unexpected. So going back will reuse the page even if no-cache or no-store is specified, which does confuse people. Other navigation (e.g. going to another site and then back, or just visiting a link or a URL) will cause a revalidation with the server as expected.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.