Knowledge Maxxing
← Back to topic library
Dev MaxxingAdvancedDistributed Systems90 sec

Cache invalidation

Cache invalidation is removing or updating cached data once it's known to be outdated, so future requests don't keep receiving stale results.

Prerequisite: Cache

What matters

Deciding exactly when to invalidate a cache is a genuinely hard problem, since invalidating too rarely serves stale data and invalidating too often loses most of the cache's benefit.

Example

Updating a product's price in the database might trigger invalidating that product's cached page, so the next request rebuilds it with the new price.

Common misconception

Cache invalidation is not a solved, purely mechanical step; deciding what to invalidate and when is widely regarded as one of the trickier problems in software design.

Recall question

Why is deciding exactly when to invalidate a cache considered a genuinely hard problem?

Keywords and related concepts

cache invalidationstale dataconsistencycache

Related topics

Cache
Dev MaxxingAdvanced
Idempotency
Dev MaxxingAdvanced