Interview Prep/Caching

Top 30 Caching Interview Questions & Answers 2025

Prepare for system design interviews with 30+ questions on caching strategies, patterns, and distributed systems.

5 Questions~30 min read5 CategoriesUpdated 2025
Practice Caching Quiz

Strategies

011q

Cache-aside: app checks cache, loads from DB if miss. Read-through: cache loads from DB transparently. Write-through: writes go to cache and DB together. Write-behind: writes go to cache, async to DB. Refresh-ahead: proactively refresh before expiry. Choose based on: read/write ratio, consistency requirements, latency tolerance.

Invalidation

021q

Approaches: TTL expiration (simple, eventual consistency), event-driven invalidation (update on change), versioned keys (include version in key). Challenges: distributed invalidation, cache stampede. Patterns: write-through (immediate), eventual invalidation (pub/sub), surrogate keys (group invalidation). "There are only two hard things: cache invalidation and naming things."

Eviction

031q

LRU (Least Recently Used): evict oldest accessed. LFU (Least Frequently Used): evict least accessed. FIFO (First In First Out): evict oldest added. TTL-based: evict expired items. Random: simple, unpredictable. LRU most common (good general performance). LFU good for frequency-based workloads. Combine TTL with LRU for time-sensitive data.

Patterns

041q

Cache stampede: many requests hit DB simultaneously when cache expires. Prevention: (1) Locking - only one request fetches, others wait, (2) Probabilistic early expiration - refresh before TTL, (3) Background refresh - async update before expiry, (4) Stale-while-revalidate - serve stale, refresh async. Critical for high-traffic endpoints.

Architecture

051q

CDN: static assets (images, CSS, JS), geographically distributed content, edge caching. Application cache (Redis): dynamic data, session data, API responses, computed results. Database query cache: frequent queries, complex aggregations. Use layers: CDN for static, application cache for dynamic, database cache for queries. Consider: invalidation complexity, consistency needs.

Ready to test your Caching skills?

Practice with interactive quizzes and get instant feedback.

Start Free Practice