Caching layers: from CPU to CDN
How caches stack from L1/L2/L3 through RAM, application caches, and CDNs — and why each layer exists.
topic 10
Layers, invalidation, stampede protection, ETags.
How caches stack from L1/L2/L3 through RAM, application caches, and CDNs — and why each layer exists.
Strategies for evicting stale entries — TTL, event-driven purge, write-through, write-behind — and why getting it wrong corrupts user state.
Why a single TTL expiry turns a hot cache key into a flash-DDoS against the origin, and the four mechanisms — locks, single-flight, XFetch, and stale-while-revalidate — that keep the database alive.
How entity tags enable conditional GET — the server returns 304 Not Modified when content unchanged, saving bandwidth and reducing latency.
The directives — max-age, s-maxage, no-store, stale-while-revalidate — that tell every cache in the chain exactly how long to keep a response.
How SWR decouples freshness from latency — serve the cached version immediately, then update it silently, eliminating the tail-latency spike of synchronous revalidation.
When a popular key expires, all concurrent requests miss simultaneously and pile onto the database — the pattern, why it differs from stampede, and how mutex locks and probabilistic early expiry prevent it.
How to compose CDN, reverse-proxy, application, and database caches into a coherent strategy — choosing TTLs, invalidation triggers, and fallback paths that hold under real traffic.
Every unit, from the underground to the orbit. Caching is one constellation in the atlas — climb another topic and watch the next one light up.