Cache Invalidation: Keeping a Cache Honest
A cache miss is slow but correct. A stale cache hit is fast and wrong, and wrong is worse. Invalidation is the work of making sure the copy in the cache still matches the truth in the database. Here are the ways to do it, each with its own analogy and its own visualizer.
A dedicated look at cache invalidation, the hard half of caching. Why a stale hit is worse than a miss, then the four strategies to keep a cache honest: TTL expiry (bounded staleness), write-through (update on write), invalidate-on-write (delete the key and let the next read refill), and versioned or immutable keys (bump the version, never edit in place). Everyday analogies, a hand-drawn stale-window timeline, and visualizers for the delete-on-write cycle and versioned keys. Why the races make it genuinely hard, and a tee-up to the stampede.
- System Design

