awesome-everything RU
↑ Back to the climb

Caching

Cache-Control: multiple-choice review

Crux Multiple-choice synthesis across the Cache-Control unit — storage vs revalidation, shared-cache TTLs, the private leak, immutable assets, and stale serving.
Your altitude — climbing toward senior
ZeroJuniorMiddleSenior
You are at senior altitude — in orbit
◷ 13 min

Six questions across the whole unit. Each maps to a header you would actually ship — and to the silent incident that follows when a directive does something other than what its name suggests.

Goal

Confirm you can pick the right directive for storage vs revalidation, separate browser TTLs from CDN TTLs, and reason about the leaks and traps that the defaults set up.

Quiz

A team ships Cache-Control: no-cache on a bank-balance endpoint, intending that nothing is ever stored. A kiosk later shows one customer the previous customer's balance on a back-button press. What went wrong?

Quiz

You set Cache-Control: max-age=0 on your HTML to keep browsers always fresh. A CDN sits in front. With no s-maxage, what happens at the CDN?

Quiz

An authenticated /account route is served with Cache-Control: public, max-age=300 behind a CDN. Every visitor for the next five minutes sees the first user's account page. The root cause?

Quiz

Static bundles are served with Cache-Control: public, max-age=31536000, immutable. What single practice makes a one-year cache safe rather than a one-year bug?

Quiz

A CDN-fronted JSON API ships Cache-Control: max-age=60, s-maxage=300, stale-while-revalidate=3600. What is the resulting behaviour?

Quiz

A response sets Vary: Cookie to keep a logged-in page off shared caches. Why is this an unreliable safety mechanism for per-user content?

Recap

The unit’s through-line is one decision tree. First ask whether a cache may store the response at all: no-store is the only directive that forbids storage, and no-cache merely forces revalidation, which is why no-cache leaks sensitive data into the browser and bfcache. Then separate the tiers: max-age governs every cache, s-maxage overrides it for shared caches only, and private keeps per-user responses off the CDN — its absence on an authenticated route is the classic data-leak. For static assets, public, max-age=31536000, immutable is correct only with content-hashed filenames, because a changed file then changes the URL. stale-while-revalidate and stale-if-error trade staleness for latency and resilience, and Vary keys variants rather than excluding sharing — so the real safety always lives in private/no-store.

Continue the climb ↑Cache-Control: free-recall review
shortcuts expand
search
K
prev piece
k
next piece
j
cycle tier
t
this menu
?
sources3
expand
  1. 01
  2. 02
  3. 03

Trademarks belong to their respective owners. Editorial reference only.