19. How do you use caching, and what can go wrong?
MediumSystem design
Technical
Show model answer
Caches keep frequently read data close to the reader (browser, CDN, in-memory stores such as Redis) to cut latency and load. Common patterns are cache-aside, write-through and write-back, with eviction such as LRU and a time-to-live.
Problems: stale data and invalidation, cache stampedes when a hot key expires (use locking or staggered TTLs), and cold-start load. Only cache data whose staleness you can tolerate.