Where do you add caching, and what are the common caching patterns?
Reviewed by Gurusankar M.
β‘ Short Answer
Cache at multiple layers (browser/CDN, app, DB). Patterns: cache-aside (app loads on miss, most common), write-through (write cache+DB together), write-behind (async). Always set a TTL and a sensible eviction policy (LRU) β and remember cache invalidation is the hard part.
βCoffee Chat Question
Concept Made Simple
βWhere do you add caching, and what are the common caching patterns?β
π§ Mind Map Answer
Remember It Faster
π₯What If?
Think Beyond the Expected
What is a cache stampede, and how do you prevent it?
When a hot key expires, many requests miss simultaneously and all hit the DB at once (thundering herd). Prevent it with request coalescing (single flight β one loader, others wait), slightly randomized TTLs (jitter), or serving stale-while-revalidate.
πReal World
Cache-aside with Redis is the default; the classic incidents are stale data (bad invalidation) and cache stampedes on hot keys β solved with TTL jitter and single-flight loading.
π―Interviewer's Expectation
Keywords they're listening for:
β οΈCommon Mistakes
- βNo TTL (stale forever)
- βNo stampede protection on hot keys
- βCaching data that must be strongly consistent
β Best Practices
- βCache-aside + TTL with jitter
- βSingle-flight loading for hot keys
- βPlan invalidation explicitly
πFollow-up Questions
- 1Cache-aside vs write-through β trade-offs?
- 2How do you keep the cache consistent with the DB?
- 3What is stale-while-revalidate?
π§©Related Technologies
Continue Learning with AI
Take this question deeper with your favourite AI assistant. Pick a depth, copy the prompt, or open it directly β AI is your learning companion, not a shortcut.
Plain-language foundations
I'm preparing for a software engineering interview and want to understand this from scratch, as a beginner. Topic: Caching (System Design) Interview question: "Where do you add caching, and what are the common caching patterns?" Please: 1. Explain the core idea in simple, plain language, using an everyday analogy. 2. Define any technical terms you use. 3. Walk through one small, concrete example. 4. Finish with a single sentence I can easily remember. Keep the tone friendly and assume I'm new to this topic.
Was this answer helpful?
β Featured Products
Support our platform by exploring our recommended products.
As an Amazon affiliate, purchases through these links may earn us a small commission β at no extra cost to you. It helps keep Full Stack Interview Guru free.