Cache invalidation strategies

Slap yourself if

You think cache invalidation is just setting a max-age or believe stale data bugs are rare edge cases.

Why this exists

Because most production data inconsistencies, phantom bugs, and 'it fixed itself on refresh' incidents are cache invalidation failures, not logic errors.

Mental model

Caching is a contract between producers and consumers with time, identity, and scope. Invalidation is breaking that contract safely — which is always harder than filling the cache.

  • Data is cached at multiple layers with different lifetimes.
  • Each layer makes independent freshness decisions.
  • Invalidation signals propagate imperfectly or not at all.
  • Users observe mixed states depending on which cache they hit.
  • Relying on time-based expiration for correctness.
  • Invalidating one layer while others remain stale.
  • Assuming reloads clear all caches.
  • Coupling cache keys too loosely or too tightly.

Cache invalidation is the process of safely expiring or bypassing cached data across layers, trading freshness, consistency, and performance.

  • Quotes 'there are only two hard things' without specifics.
  • Focuses only on TTLs.
  • Ignores multi-layer caches.
  • Assumes eventual consistency is acceptable by default.

Deep dive

Requires Pro

Premium deep dives include more internals, more scars.

Why invalidation is a multi-layer problem

How partial invalidation breaks user trust

Time-based vs version-based vs explicit invalidation

How to prove a cache is lying to you

How cache answers expose shallow systems thinking