Caching · Request & Response
Cache-Control
Directives that control caching behavior.
What is Cache-Control?
Cache-Control is the primary way to instruct browsers and CDN caches how, and how long, a response can be reused. It supersedes older headers like Expires and Pragma.
Typical usage
Set on almost every response. Static assets get long max-age + immutable; HTML gets short max-age or no-store; sensitive responses get no-store.
Examples
Static asset, cache forever
Cache-Control: public, max-age=31536000, immutableHTML, revalidate every time
Cache-Control: no-cachePrivate data, never store
Cache-Control: no-storeCDN caches 1 hour, browsers 1 min
Cache-Control: public, s-maxage=3600, max-age=60Common gotchas
no-cache does NOT mean 'don't cache' — it means 'cache, but revalidate every time'. Use no-store if you want zero caching. Confusing these two is one of the top HTTP mistakes.
Also known as
Also commonly written as: cache control · cache-control header · cache control header · cache-control max-age · cache-control no-cache · cache-control no-store · cache-control immutable · cache-control s-maxage · http caching header · Cache-Control ヘッダ. These variants — including plural forms, unhyphenated spellings, and Japanese (ヘッダ) — all refer to the same Cache-Control HTTP header.
Specification
RFC 9111
Frequently asked questions
What is the Cache-Control HTTP header?
Cache-Control is the primary way to instruct browsers and CDN caches how, and how long, a response can be reused. It supersedes older headers like Expires and Pragma.
Is Cache-Control a request or response header?
Cache-Control can appear on both requests and responses. Set on almost every response. Static assets get long max-age + immutable; HTML gets short max-age or no-store; sensitive responses get no-store.
What does a Cache-Control header look like?
A typical Cache-Control header looks like: Cache-Control: public, max-age=31536000, immutable (Static asset, cache forever).
What are common mistakes with Cache-Control?
no-cache does NOT mean 'don't cache' — it means 'cache, but revalidate every time'. Use no-store if you want zero caching. Confusing these two is one of the top HTTP mistakes.
Related headers
ETag
A version identifier for the resource — the backbone of conditional GETs.
Expires
Declares a wall-clock deadline (HTTP-date) for how long the response stays fresh. Includes exact format, 4 production-ready server configs (Apache, Nginx, Express, CDNs), and the deprecation caveats with Cache-Control.
Vary
Which request headers cause different cached variants of the response.
Age
How many seconds the response has been in a shared cache.
Date
When the response was generated.
Last-Modified
When the resource was last modified.
If-None-Match
Send the resource only if its ETag has changed.
If-Modified-Since
Send the resource only if it changed after this date.