Caching
Caching capstone: multiple-choice review
Six questions that cut across the whole track. None tests a single directive in isolation — each asks you to reason about how two or more layers compose, which is where real caching bugs live.
Confirm you can wire layer ownership, TTL cascade, stampede protection, validators, and stale-while-revalidate into one coherent strategy — the synthesis the individual units built toward.
A request passes through CDN, reverse proxy, Redis, and the DB. An editor changes a product, the write path updates the DB and deletes the Redis key, but users still see the old price for an hour. Where is the bug?
You set the CDN to s-maxage=3600 but the app revalidates its Redis fragment every 60s. Why is this a composition bug regardless of which numbers are correct individually?
A hot key with thousands of concurrent readers expires. You can add (a) a per-key mutex so one request recomputes while the rest wait, or (b) stale-while-revalidate. A senior usually reaches for SWR first. Why?
A public API read costs 40ms to compute and changes rarely. You want low latency, low origin load, and bandwidth savings on the wire. Which combination composes these correctly?
A logged-in dashboard renders per-user billing data and sits behind a shared CDN. The handler returns 200 with no Cache-Control. What is the actual risk, and the correct fix?
Across the stack, which statement about failing open during an origin outage is correct?
The track’s through-line is one composed strategy: assign each layer the data it owns, shrink freshness windows outward (or purge the outer layer on every inner change), protect the origin on a hot-key expiry with single-flight or SWR, save bandwidth with ETag-driven 304s, scope per-user responses with private/no-store, wire invalidation into the write path so it propagates Redis → proxy → CDN in order, and fail open with stale-if-error tuned per resource. No single directive is the answer; the answer is how the layers compose.