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 memoized per process behaves like a cache within one instance and like nothing at all across several. See Incremental Static Regeneration.
See also11
Determinism
The property that identical inputs produce identical outputs, and the foundation of caching and verification.
Systems & Tooling61 connections
Static Site Generation
Rendering every page to a file at build time, so serving is just handing over bytes.
Web Platform19 connections
React Server Components
Components that execute only on the server and never ship their code to the browser.
Web Platform21 connections
Domain Name System
The distributed directory translating names to addresses, and the layer where propagation delays live.
Systems & Tooling27 connections
Server-Side Rendering
Producing a page's HTML on the server so the first response is already content.
Web Platform23 connections
Record and Replay Testing
Capturing a real interaction once and replaying it deterministically in later test runs.
Agents & Language Models14 connections
Write-Behind Cache
A cache that acknowledges a write immediately and persists it to the real store later, trading durability for write latency.
Data & Content5 connections
Naming
Choosing identifiers so the code states its own meaning without commentary.
Method59 connections
Hash Function
A function mapping arbitrary input to a fixed-size digest, used for identity, integrity, and addressing.
Systems & Tooling30 connections
Materialized View
The stored result of a query, kept as a table so that expensive reads become cheap, at the cost of keeping that result up to date.
Data & Content9 connections
Time to Live
A limit on how long something may live, counted in hops or seconds, which keeps lost packets from circling forever and tells caches when their copies go stale.
Networks & Distribution11 connections
Linked from27
- Back-Forward CacheWeb Platform
Browsers keeping a whole page frozen in memory when you navigate away, so pressing Back restores it instantly, unless something on the page makes it ineligible.
- Bloom FilterComputation & Algorithms
A probabilistic set membership structure that can say "definitely not present" but only "probably present."
- Build CacheVersion Control & Delivery
Reusing the outputs of build and test steps whose inputs haven't changed, keyed by a hash of those inputs, so large codebases build in minutes instead of hours.
- Change Data CaptureData & Content
Turning a database's own internal write log into a stream other systems can subscribe to, without touching the application.
- Consistent HashingComputation & Algorithms
A hashing scheme where adding or removing a node remaps only a small fraction of keys, not nearly all of them.
- Content Delivery NetworkNetworks & Distribution
A CDN answers requests from servers near the requester, trading a single origin for many cached edges.
- 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.
- ETagWeb Platform
An opaque fingerprint of a response's content that lets a client ask a server whether it's changed without re-downloading it.
- 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.
- HTTP CachingWeb Platform
The set of headers that let a browser or intermediary reuse a previous response instead of re-fetching it.
- Incremental Static RegenerationWeb Platform
Serving a cached static page while regenerating it in the background after a chosen interval.
- JSON Web TokenWeb Platform
A signed, self-contained token that carries claims a server can verify without a database lookup.
- Least Recently Used CacheComputation & Algorithms
A fixed-capacity cache that evicts whichever entry has gone untouched the longest.
- Materialized ViewData & Content
The stored result of a query, kept as a table so that expensive reads become cheap, at the cost of keeping that result up to date.
- Open GraphWeb Platform
The meta tags a page uses to describe its own preview card when a link is shared, how chat apps and social networks fetch them, and why a preview shows only what the page claims about itself.
- Optimistic UIWeb Platform
Updating the UI as if a server request has already succeeded, before the server has actually responded.
- Progressive Web AppWeb Platform
A website that can be installed like a native app, launched from the home screen in its own window and used offline, built from a manifest, a service worker and HTTPS.
- Prompt CachingAgents & Language Models
Reusing the computed state of a prompt's unchanged prefix across requests, which only works if that prefix stays byte-identical.
- React Server ComponentsWeb Platform
Components that execute only on the server and never ship their code to the browser.
- Shader Compilation StutterGraphics & Rendering
Frame hitches caused by compiling GPU programs the first time they are needed, and the caching schemes that try to move that work elsewhere.
- State ManagementWeb Platform
How a front-end application keeps track of the data that changes as people use it, and decides where each piece lives, from local component state to global stores to server caches.
- Static Site GenerationWeb Platform
Rendering every page to a file at build time, so serving is just handing over bytes.
- Time to LiveNetworks & Distribution
A limit on how long something may live, counted in hops or seconds, which keeps lost packets from circling forever and tells caches when their copies go stale.
- Write-Behind CacheData & Content
A cache that acknowledges a write immediately and persists it to the real store later, trading durability for write latency.