Caching interview question · Most asked
In a system design interview, how do you decide what and where to cache?
Summary
Identify read-heavy, expensive or latency-sensitive paths and their staleness tolerance; pick the closest safe layer (CDN for public content, Redis for shared computed data, local cache for config); define keys, TTLs, invalidation and stampede protection; and estimate hit ratio, memory size and the load the database must still handle.
Longer Answer
State failure behavior (cache down), consistency guarantees (eventual, read-your-writes) and how you'd monitor effectiveness.
Key Points
- Target hot, expensive reads
- Choose the layer by audience
- Keys, TTLs, invalidation
- Capacity and failure plans
More most-asked Caching questions
- Explain the main caching patterns: cache-aside, read-through, write-through and write-behind.
- Why is cache invalidation hard, and what strategies help?
- What is a cache stampede (thundering herd) and how do you prevent it?
- How does HTTP caching work (Cache-Control, ETag, CDNs)?
- Explain the difference between cache penetration, cache breakdown and cache avalanche.
- In cache-aside, why can a value be stale even though you delete the key on every write?
- How can a CDN leak one user's data to another, and how do you prevent it?
- How does stale-while-revalidate work, and when is it inappropriate?