Scalability and Performance · Remembering answers
Cache invalidation strategies
A cached copy is a bet that the data has not changed. Invalidation strategies decide how the bet ends (by timer, delete, overwrite, version or event) and each fails in its own way.
- Time22 min
- LevelDeveloper
- Pictures13 diagrams
- Check6 questions






Reader A misses product:42 and queries the database.
Database returns the old price, 10, but A's reply is delayed.
Writer B commits price 12, then deletes product:42.
Reader A finally stores price 10 under product:42, after the delete.
Everyone reads price 10 from the cache until the TTL expires.
Account balance read from the primary database; not cached.
Stock level cached a few seconds; checkout re-checks the database.
Product description cached for minutes; delete on write speeds up corrections.
Fingerprinted static file cached for a year; a new version gets a new URL.