Skip to content

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.

ready.lu editors
Speed
  • 3 min read
  • 3 questions for your Radar

In short

  • Fingerprinted assets: cache for a year with immutable. HTML: short and revalidated.
  • no-cache does not mean "don't cache" — it means "check before reuse". no-store means don't keep it.
  • s-maxage and stale-while-revalidate let 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.

1 headerdecides whether a traffic spike reaches your server once a minute — or once for every single visitor.

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). Overrides max-age for 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.
Check yourself · Speed & CDN1 / 3

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

http
GET /assets/app.3f9a1c.js
Cache-Control: public, max-age=31536000, immutable

When 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

http
GET /products/espresso-machine
Cache-Control: public, max-age=0, s-maxage=60, stale-while-revalidate=300

Browsers 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.

Check yourself · Speed & CDN2 / 3

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

http
GET /account
Cache-Control: private, no-store
ready.lu console · CDNSimulated data
ready.lu edgecopies kept hereYour serverasked only when needed
Answered by the edgeFetched from your serverExample timings
Simulated edge: copies served from cache never reach the server — the hit ratio is what your server was spared.

Measure 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.

Check yourself · Speed & CDN3 / 3

Your hit ratio is 35% and your CSS files are served with max-age=0. What is the most likely first improvement?

Readers' poll

Do you know what Cache-Control header your homepage sends right now?

Your caching checklist

0 of 6 done

Ticks are kept in this browser only. Create a free account to keep them on every device.

Check what an assistant suggests before you apply it, and keep a backup. General advice — every server is different.
Your result

0 / 3 right

3 questions above are waiting for you.

Speed
0.0/10
Level
Curious
Week streak
0
SecurityBotsSpeedAnalyticsServersSearchUXUI
Useful? Keep it for later, or pass it on.

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

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.

Cache-Control explained: max-age, s-maxage, no-cache | Ready Journal