Cache-Control in plain words: make your server do less
One response header decides whether your server works for every visitor or for almost none. The seven directives that matter, the one everybody misreads, and a policy you can copy.
- 3 min read
- 3 questions for your Radar
- A checklist to keep
- A poll: compare with other readers
In short
- Fingerprinted assets: cache for a year with
immutable. HTML: short and revalidated. no-cachedoes not mean "don't cache" — it means "check before reuse".no-storemeans don't keep it.s-maxageandstale-while-revalidatelet a CDN absorb traffic without serving stale pages for long.
Every response your server sends can carry instructions for the caches between you and your visitors: their browser, and any CDN or proxy on the way. Without instructions, caches guess — usually cautiously, so your server rebuilds the same page for every visitor. With the right ones, most requests never reach it.
The seven directives that matter
max-age=N— any cache may reuse the response for N seconds without asking.s-maxage=N— the same, for shared caches only (CDN, proxy). Overridesmax-agefor them; browsers ignore it.no-cache— a cache may keep a copy but must revalidate with the server before each reuse.no-store— keep no copy anywhere. For pages with personal or sensitive data.private— only the visitor's browser may keep it; shared caches must not.immutable— the response will not change while fresh: browsers skip revalidation even on reload.stale-while-revalidate=N— after expiry, serve the old copy for up to N seconds while fetching a new one in the background.
Your banking-style account page is served with Cache-Control: no-cache. Is it kept out of caches?
A policy you can copy
Assets with a fingerprint in the name
GET /assets/app.3f9a1c.js
Cache-Control: public, max-age=31536000, immutableWhen the file changes, its name changes, so a year-long lifetime is safe. This single rule removes the bulk of your traffic.
HTML pages that are the same for everyone
GET /products/espresso-machine
Cache-Control: public, max-age=0, s-maxage=60, stale-while-revalidate=300Browsers always check; the CDN answers for a minute, then keeps serving the old page for up to five minutes while it refreshes. A traffic spike hits your server about once a minute, not once per visitor.
With s-maxage=60, stale-while-revalidate=300, a page expired 2 minutes ago at the CDN. A visitor arrives. What happens?
Pages with personal content
GET /account
Cache-Control: private, no-storeMeasure the result
Look at your CDN's hit ratio: the share of requests answered from cache. For a brochure site, above 80% is normal once assets are fingerprinted. Then check the server: CPU and response times usually drop with it.
Your hit ratio is 35% and your CSS files are served with max-age=0. What is the most likely first improvement?
Do you know what Cache-Control header your homepage sends right now?
Your caching checklist
0 of 6 doneTicks are kept in this browser only. Create a free account to keep them on every device.
0 / 3 right
3 questions above are waiting for you.
- Speed
- 0.0/10
- Level
- Curious
- Week streak
- 0
Questions people ask
What is the difference between no-cache and no-store?
no-cache lets a cache keep a copy but requires it to check with the server before reusing it. no-store forbids keeping a copy at all.
What does s-maxage do?
It sets how long shared caches — a CDN or a proxy — may reuse a response, overriding max-age for them only. Browsers ignore it.
How should I cache CSS and JavaScript files?
Give each build a fingerprinted file name (app.3f9a1c.js) and serve it with Cache-Control: public, max-age=31536000, immutable. A new build gets a new name, so the long lifetime never serves stale code.
Related reading
- Bots
Not every bot is a burglar: a field guide to the crawlers on your website
On a close subject · 3 min
Stuck on something? We write it next.
A question you keep googling, a problem on your server, a myth you want busted — readers’ ideas go first into the daily selection.
Be first to the next article
New questions for your Radar come with every article. One short email when it is out; nothing else.