72
cache invalidation
A cache is a lie with a deadline. Say who deletes it, and when.
What is cache invalidation?
Invalidation removes or refreshes a cached value when the source changes. TTL alone means you serve stale data until the clock saves you. Explicit purge means the write path knows the key.
Why does cache invalidation matter when vibe coding?
Models add Redis or HTTP cache headers and never a purge. You change a title and the public page stays old. Name the key and the event that kills it.
How do you do cache invalidation?
Every cache key has a writer who deletes or updates it. Prefer “purge on write” for anything a human just edited. TTL is for tolerance, not for correctness.
How do you ask a model for cache invalidation?
Cache (thing) under a key that includes (id). On write, delete that key. Do not rely on a long TTL for a page a user just edited.
What goes wrong with cache invalidation?
Caching a per-user response under a global key. One user’s data becomes everyone’s. The key must include the viewer.