Cache-Control is an HTTP header made of one or more directives, separated by commas. Your server sends it with a response to say who may store that response and for how long:
Cache-Control: public, max-age=3600
This one says: any cache, including a CDN, may store this response and reuse it for 3,600 seconds (one hour) without asking the server again. Browsers can send Cache-Control in requests too. When you force-reload a page, the browser usually adds no-cache to ask caches to check with the server first.
The directives you'll use most
| Directive | What it tells caches |
|---|---|
max-age=N |
The response stays fresh for N seconds |
s-maxage=N |
Like max-age, but only for shared caches such as CDNs, and it overrides max-age there |
no-cache |
You may store it, but check with the server before every reuse |
no-store |
Don't store it anywhere |
private |
Only the visitor's own browser may store it, not a CDN or proxy |
public |
Shared caches may store it, even for requests that carried login credentials |
must-revalidate |
Once it's stale, don't reuse it without checking with the server |
immutable |
It won't change while fresh, so don't check even on reload |
stale-while-revalidate=N |
For N seconds after it goes stale, reuse it while fetching a fresh copy in the background |
These definitions follow MDN's reference. MDN
no-cache doesn't mean "don't cache"
This is the mix-up behind most caching bugs. no-cache lets caches store a response but makes them ask the server before each reuse. If the file hasn't changed, the server answers 304 Not Modified without a body, so the check is cheap.
no-store is the one that stops storing altogether. Use it for responses that must never sit on a disk, such as pages with bank details.
You'll also see max-age=0. It began as a workaround for old HTTP/1.0 caches that didn't support no-cache. On its own it can still let a cache serve a stale copy when the server can't be reached. MDN's advice for always-current content is simply no-cache.
Pick the header by type of file
Versioned static files (CSS, JavaScript, images with a hash or version in the name, such as app.3f9a.css):
Cache-Control: public, max-age=31536000, immutable
A year, with no checks. When the file changes, its name changes, so caches fetch the new URL. This is called cache busting.
HTML pages:
Cache-Control: no-cache
Every visit checks with the server, so visitors see your latest page, and the versioned files it links to come straight from the cache.
Pages for one signed-in user:
Cache-Control: private, no-cache
The browser may keep a copy, a CDN may not. For sensitive data, use no-store instead.
A CDN that should hold pages longer than browsers:
Cache-Control: max-age=60, s-maxage=3600
Browsers check back after a minute; the CDN keeps its copy for an hour. Purge the CDN when you publish a change.
Don't stack conflicting directives. private, no-cache, no-store, max-age=0 means no more than no-store.
What happens without the header
Caches may store a response anyway and guess how long it stays fresh. The HTTP standard suggests about 10% of the time since the file's Last-Modified date. RFC 9111 So a page last changed 30 days ago could be served from a cache for about three days. If caching matters to you, set the header.
Where Expires and Vary fit in
Expires is the older header and holds a fixed date. When a response has both, caches ignore Expires and follow max-age, so you only need Cache-Control.
Vary tells caches to keep separate copies by a request header. For example, Vary: Accept-Language stores one copy per language.
Cache-Control and SEO
Cache-Control doesn't decide whether a page is indexed. For that, use the robots meta tag or the X-Robots-Tag header.
It does affect how fast pages load, especially for returning visitors, and that feeds into Core Web Vitals. Google's crawlers support conditional requests with ETag and Last-Modified, and Google suggests also setting max-age to the number of seconds you expect the content to stay unchanged. That helps its crawlers decide when to come back. Google Search Central See cache for how that works.
Check a page's headers
Open your browser's developer tools, go to the Network tab, reload, and click a file to see its response headers. From a terminal:
curl -sI https://example.com/
Cache-Control only shapes what caches do from now on. To remove copies a CDN already holds, purge them in the CDN. Proxies you don't control keep their copies until they expire, and browsers keep theirs until they expire or get a Clear-Site-Data: cache header from your site.