Cache Invalidation
Deciding when a cached value has stopped being correct — famously one of the hard problems.
Cache invalidation is the problem of knowing when a stored copy of a computed value is no longer valid. Phil Karlton's line — that the two hard things in computer science are cache invalidation and naming things — endures because both are about maintaining a correspondence that nothing enforces.
The available strategies are few. Time-based expiry is simple and always either too eager or too stale. Event-based invalidation is precise and requires every writer to know every cache. Content-based keys — a Fingerprint over the inputs — invalidate exactly when they should and require the inputs to be enumerable. Immutable, content-hashed asset filenames are the last strategy taken to its conclusion: nothing is ever invalidated because nothing is ever overwritten.
Caches also multiply invisibly. A single request may pass through a browser cache, a CDN, a framework's data cache, an application memo, and a database query cache — each with its own lifetime. A change that appears in one and not another produces the characteristic "it works on my machine, and also on yours, but not for anyone else" report.
The subtlest form is a cache whose scope is smaller than assumed: a value memoised per process behaves like a cache within one instance and like nothing at all across several. See Incremental Static Regeneration.
See also7
Hand-picked in the note itself — the neighbours worth reading next.
Fingerprint
A hash over everything that determined a result, used to detect when the result has gone stale.
Agents & Language Models11 connections
Determinism
The property that identical inputs produce identical outputs, and the foundation of caching and verification.
Systems & Tooling27 connections
Naming
Choosing identifiers so the code states its own meaning without commentary.
Method21 connections
Static Site Generation
Rendering every page to a file at build time, so serving is just handing over bytes.
Web Platform12 connections
Hash Function
A function mapping arbitrary input to a fixed-size digest, used for identity, integrity, and addressing.
Systems & Tooling7 connections
React Server Components
Components that execute only on the server and never ship their code to the browser.
Web Platform16 connections
Domain Name System
The distributed directory translating names to addresses, and the layer where propagation delays live.
Systems & Tooling4 connections
Related2
Nearby in the graph rather than deliberately chosen. Looser, sometimes surprising.
Linked from8
Notes elsewhere in the wiki that reach for this one.
- DeterminismSystems & Tooling
The property that identical inputs produce identical outputs, and the foundation of caching and verification.
- Domain Name SystemSystems & Tooling
The distributed directory translating names to addresses, and the layer where propagation delays live.
- Eventual ConsistencyNetworks & Distribution
A guarantee that replicas converge given no further updates, without guaranteeing when.
- FingerprintAgents & Language Models
A hash over everything that determined a result, used to detect when the result has gone stale.
- Hash FunctionSystems & Tooling
A function mapping arbitrary input to a fixed-size digest, used for identity, integrity, and addressing.
- Incremental Static RegenerationWeb Platform
Serving a cached static page while regenerating it in the background after a chosen interval.
- React Server ComponentsWeb Platform
Components that execute only on the server and never ship their code to the browser.
- Static Site GenerationWeb Platform
Rendering every page to a file at build time, so serving is just handing over bytes.