Cache Invalidation
Updated 2026-08-02
Summary
The problem of keeping cached copies consistent with the source data whenever that data changes, a task famous for having no perfect solution.
Definition
Cache invalidation is the discipline of deciding when a stored copy of data must be discarded or refreshed because the original changed. It is often called one of the two hard problems in computer science, alongside naming things, because any strategy trades freshness against speed and complexity. Write-through, write-behind, and time-based expiry are common policies, and each leaves a window in which readers can see stale values.
Introduction
How to use
- Name the trade: state whether you are buying speed at the cost of temporary inconsistency - Bound the staleness: decide how long a stale copy may survive and enforce that limit - Invalidate on change: update or drop the copy the moment the source moves rather than hoping
Mechanism
A cache serves stale data whenever the source changes without the copy being told. The faster the cache, the longer the interval during which readers may act on outdated values. Because every policy must choose when to refresh, consistency and latency cannot both be maximized, and the residual risk has to be managed rather than eliminated.
Practice
In progress 0/1Practice this model in one real situation:
Cases
- Production incidents often trace to a cache serving an outdated value after a database update.
- Content delivery networks accept short staleness windows so pages load fast, which occasionally shows deleted content.
Common pitfalls
- Ignoring races in which an invalidation and a write arrive in the wrong order and leave stale data.
- Assuming a cache can be made perfectly consistent, which would remove the performance benefit that justified it.
Sources
Source support: Explicit
References currently contain only Wikipedia links; primary sources still need review.
- en.wikipedia.orghttps://en.wikipedia.org/wiki/Cache_invalidationverified
account_treeGenealogyexpand_more
PRIVATE NOTES · Only visible to you
SAVED Q&A
ENTRY Q&A · Private saving available
Ask with a clear boundary
thinkingmodels answers from published entry context only.
Your question is sent to thinkingmodels. The answer uses public entry context only.
RELATED MODELS