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.
On this page
Concept Made Simple
Coffee Chat Question
“Where do you add caching, and what are the common caching patterns?”
Remember It Faster
Mind Map Answer
- Cache-aside
- load on miss, app-managed (common)
- Write-through
- write cache + DB together
- Write-behind
- write cache, flush to DB async
- Always
- TTL + eviction (LRU)
Think Beyond the Expected
What If?
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:
- cache-aside/write-through/behind
- TTL + eviction
- invalidation is hard
- stampede/thundering herd
- multi-layer caching
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
- Cache-aside vs write-through — trade-offs?
- How do you keep the cache consistent with the DB?
- What is stale-while-revalidate?
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?
Affiliate links
Tools for Your Developer Workspace
Equipment for a comfortable, productive setup.
As an Amazon Associate I earn from qualifying purchases.
- MonitorView on Amazon : BenQ EW2790U 27-inch Monitor (opens in a new tab)
BenQ EW2790U 27-inch Monitor
- LaptopView on Amazon : Acer Aspire One Laptop (opens in a new tab)
Acer Aspire One Laptop
- Office ChairView on Amazon : Wakefit Gravita Ergonomic Office Chair (opens in a new tab)
Wakefit Gravita Ergonomic Office Chair