Cognitive Scaffold

Preparing your thinking workspace

arrow_back_ios_new
MENTAL MODEL · M4579

Cache Invalidation

Cache Invalidation
SystemsHigh supportSystems Theory
Included
account_tree

Updated 2026-08-02

Loading revision record…

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.

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/1

Practice this model in one real situation:

Check to track your progress (stored locally)
Learning progress0%

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.

  • link
    en.wikipedia.orghttps://en.wikipedia.org/wiki/Cache_invalidationZH · Explicit
    verified
account_treeGenealogyexpand_more

RELATED MODELS