Cache invalidation — keeping cached data consistent with the source of truth — is famously one of the hardest problems in computing. The challenge is ensuring caches don't serve stale data while balancing performance, consistency, and complexity. Several strategies and pitfalls are worth understanding.
The core problem
When the source data changes, the cached copy becomes STALE.
→ Serve stale data? (fast but wrong) vs invalidate? (consistent but complex/slower)
→ "There are only two hard things in CS: cache invalidation and naming things."
The difficulty: knowing WHEN and WHAT to invalidate, across distributed systems,
without races, while keeping good cache hit rates.
