HTTP headers used for browser caching. The following is generally a good one to use for a balance of fresh files + cache efficiency.
Cache-Control: public, max-age=0, s-maxage=60, must-revalidate
- The response can be cached by both a shared proxy (e.g CDN cache) and the browser.
- The response should not be cached by a shared proxy, only by the browser.
- The number of seconds both a shared proxy or browser should cache the response, before being considered stale.
- The number of seconds just a shared proxy should cache the response, before being considered stale.
- Once a file is considered stale, the browser or proxy will re-request the file whilst also sending the etag hash of the current file it has (via the request header
If-None-Match=<etag provided with the initial file repsonse>). The server or shared proxy will compare the hash with its current file and send back either a
304 Not Modifiedheader response, or a
200 Okresponse with the contents of the updated file. Including an updated etag header for the new file.
The kind of traffic for doing a revalidation request will be very low (under 1kb), its just headers.
Open the network tab on this page and check, make sure "disable cache" is unticked, and press refresh.
Browser <---> Shared Proxy <---> Server