Caching, Explained
A cache is a copy of an expensive-to-produce answer kept somewhere fast so you don't redo the work. This guide covers what a cache really is, where caches live, and why keeping them accurate is the genuinely hard part.
Download EPUB- What a Cache Actually Is A cache keeps a copy of an expensive-to-produce result somewhere fast, so you serve it again instead of recomputing it. A 'hit' is when the copy is there; a 'miss' is when you have to do the real work.
- Where Caches Live A single request can pass through several caches in a row: the browser's own cache, a CDN at the network edge, your application cache (in-memory or Redis), and the database's internal caches. Each layer is good at a different job.
- The Hard Part - Invalidation & Staleness Caches hold copies, so the copy can drift from the truth - that's staleness. This phase covers TTLs, eviction (LRU), write-through vs. cache-aside, and when not to cache at all.