Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How necessary it is to use "must-revalidate" in "Cache-Control: no-cache, must-revalidate"

Often I use

Cache-Control: no-cache

or

Cache-Control: max-age=0

The spec says must-revalidate is for max-stale... (the server issue max-stale?)

So if for normal web servers, Apache, or Rails with Mongrels, then I think usually there is no max-stale, so must-revalidate is not needed?

like image 585
nonopolarity Avatar asked Oct 24 '10 01:10

nonopolarity


People also ask

When to use must-revalidate?

The must-revalidate directive ought to be used by servers if and only if failure to validate a request on the representation could result in incorrect operation, such as a silently unexecuted financial transaction.

What is must-revalidate in cache-control?

The must-revalidate response directive indicates that the response can be stored in caches and can be reused while fresh. If the response becomes stale, it must be validated with the origin server before reuse. Typically, must-revalidate is used with max-age .

What happens if there is no-cache-control header?

Without the cache control header the browser requests the resource every time it loads a new(?) page.

How does cache revalidation work?

Revalidation checks occur when a browser sends a request to a cache server using If-Modified-Since or If-None-Match headers. These request headers are questions sent from the browser cache about when an object has last changed that can be answered via the ETag or Last-Modified response headers on the cache server.


1 Answers

must-revalidate should be specified by servers where it would be incorrect (and not just suboptimal) for a client to get a stale response. This applies to all requests with max-stale as you mentioned. It also applies, if a cache temporarily loses connectivity to the origin (a cache is allowed to return a stale entry with a Warning header in this case). That being said, I think you are right that this directive is not needed particularly in practice; it's seen most often in a situation where the origin wants to let a client cache a copy of the resource (for bandwidth conservation purposes) but always validate it before use, as in:

Cache-Control: private, max-age=0, must-revalidate

like image 145
Jon Moore Avatar answered Jun 17 '23 12:06

Jon Moore