Skip to content

What it is

A cache is a small, fast storage layer that holds copies of data so future requests are served faster than recomputing or re-fetching.

A cache trades space for time. It keeps a copy of something expensive — a function's result, a database row, an HTTP response, a DNS answer — in a place where reading is cheaper than recomputing. The trade only pays off when the same data is requested more than once, and when the cost of a stale copy is less than the cost of recomputing.

There are at least six cache families, and they share the same vocabulary: hit (found in the cache), miss (not found, must recompute), eviction (removing an entry to make space), TTL (time to live), invalidation (making an entry no longer valid) and coherence (all layers agree on the value).