What is the difference between no-cache and no-store in Cache-control?

I see no practical difference between Cache-Control:no-store and Cache-Control:no-cache .

As far as I know, no-store means that the cache device is not allowed to cache this response. no-cache , on the other hand, means that the cache device is not allowed to serve the cached response without first checking it with the source. But what is this validation about? Conditional get?

What if the answer has no-cache but it does not have Last-Modified or ETag ?

Sincerely.

+13
source share
3 answers

But what is this test?

Accurate Last-Modified or ETag . The client would request the server if it has a new version of the data using these headers, and if the answer is no, it will serve the cached data.


Update

From RFC

 no-cache If the no-cache directive does not specify a field-name, then a cache MUST NOT use the response to satisfy a subsequent request without successful revalidation with the origin server. This allows an origin server to prevent caching even by caches that have been configured to return stale responses to client requests. 
+12
source share
+36
source share

As you determined, no-cache does not mean that it is never cached, but rather that the user agent should always request the server, if it is ok, to use what it has cached. On the contrary, the non-store says that it does not even keep a copy, which means that there is nothing to ask about it. If you know the answer to the question "Can I reuse this?" always not, you get a performance boost due to (1) overhead gaps and (2) not discarding any, possibly reusable, saved result to make room for a new result that will never be reused.

Beyond performance, there is a difference in behavior with browser history . Section of the HTTP 1.1 specification 13.13 says that "expiration time does not apply to history engines." The no-cache header describes expiration and therefore does not apply to history mechanisms such as the back button. Thus, the user can move back to the previous page without a cache without contacting the server.

On the other hand, a header without storage prevents data from being stored outside the session, in which case it is simply not available to use the history mechanism. If there is no store, if the user ends his session by going to another domain and then returns, the only way for the browser to find out what to display is to get the original page from the server again.

Here's how the Chromium issue on this issue makes a distinction:

no-cache does not mean "do not cache this" (it will be non-storage). no-cache tools do not use this for normal workloads unless the resource is reevaluated for freshness. Navigating through history are not normal loads.

+2
source share

All Articles