$ cd ..
2026-03-14
A smaller way to think about caching
Most caching bugs I've hit come from treating the cache as a second source of truth instead of what it actually is: a bet that something won't change before you look at it again.
Once I started naming that bet explicitly — what's the key, what invalidates it, how wrong can the answer be before it matters — a lot of the usual problems stopped happening. Stale data stopped being a mystery and became a missing invalidation rule I could point to.
It also made caches easier to delete. If you can't say what the bet was, you probably can't say whether it's still worth making.