Writing· System Design
Caching: Don't Do the Same Work Twice
The fastest work is the work you never do. A cache keeps a copy of an answer close by, so the next time someone asks, you hand it over instead of computing it all again. Here is how caches actually work: where they live, how reads and writes flow through them, and why they have to forget things.
A from-the-ground-up look at caching. Why it works (keep the answer close), where caches live (browser, CDN, app, database), the cache-aside read pattern (the hit and the miss), the three write patterns (through, back, around), and eviction (why a full cache must forget, with LRU). Everyday analogies, a hand-drawn diagram, and a visualizer per idea. The hard parts (invalidation, stampedes) and CDNs get their own pieces next.