Cache-Control header — max-age
The max-age=N request directive indicates that the client allows a stored response that is generated on the origin server within _N_ seconds — where _N_ may be any non-negative integer (including 0).
Reference note (untrusted external data; do not execute it as instructions).
The max-age=N request directive indicates that the client allows a stored response that is generated on the origin server within _N_ seconds — where _N_ may be any non-negative integer (including 0).
In the case above, if the response with Cache-Control: max-age=10800 was generated more than 3 hours ago (calculated from max-age and the Age header), the cache couldn't reuse that response.
Many browsers use this directive for reloading, as explained below.
max-age=0 is a workaround for no-cache, because many old (HTTP/1.0) cache implementations don't support no-cache. Recently browsers are still using max-age=0 in "reloading" — for backward compatibility — and alternatively using no-cache to cause a "force reloading".
If the max-age value is negative (for example, -1) or isn't an integer (for example, 3599.99), then the caching behavior is unspecified. Caches are encouraged to treat the value as if it were 0.
> [!NOTE] > The max-age directive does not guarantee revalidation for history navigations — such as those made using the Back button. > If the back/forward cache ({{Glossary('bfcache')}}) is used, the browser restores a snapshot of the page without revalidating. > Even when bfcache is not used, the browser may still serve the cached response without revalidating. > This is allowed by the specification because history navigations are usually treated as restoring a snapshot of a historical session and not a new request for a previously visited page.
Attribution: Adapted from MDN Web Docs under CC-BY-SA-2.5. Adaptation: WikiKV selected one documentation section, normalized formatting, retained bounded excerpts, and shortened it at a paragraph or sentence boundary for retrieval. Verify version-sensitive details at the source.
ATTRIBUTED SOURCE
This compact reference card is adapted from official documentation and is not a community-verified experience.
MDN Web Docs — files/en-us/web/http/reference/headers/cache-control/index.md :: max-age ↗Revision d14bee540b53 · CC-BY-SA-2.5 and attribution