What is a cache, and what are the primary reasons for adding one to a system?
Junior
What is the difference between a cache hit and a cache miss, and what do we mean by a 'cold' versus a 'warm' cache?
Junior
What is the difference between memoization and caching?
Junior
When is caching actually a bad idea? Can you name scenarios where adding a cache would decrease performance or reliability?
Mid
How does the principle of temporal and spatial locality justify the use of a cache in the first place?
Mid
Why might you choose NOT to cache a piece of data even if it is frequently accessed?
Mid
Under what circumstances might adding a cache actually increase the overall latency of a request?
Mid
What makes a good cache key? What pitfalls should you avoid when designing cache keys?
Mid
What characteristics make a piece of data a good candidate for caching versus a poor one?
Mid
What are virtual nodes in consistent hashing and what problem do they solve?
Senior
Why is the choice of serialization format (JSON vs. Protobuf vs. Binary) important when designing a high-performance caching layer?
Senior
Caching Patterns
What is the fundamental difference between the Cache-Aside (Lazy Loading) pattern and the Read-Through pattern, and in which layer does the loading logic reside for each?
Mid
Explain the trade-off between Write-Through and Write-Back (Write-Behind) caching. Which one would you choose for a system where data loss is unacceptable, and why?
Mid
When would you use a Write-Around policy instead of Write-Through, and how does it impact the cache miss rate for subsequent reads?
Mid
Compare Write-Through, Write-Back (Write-Behind), and Write-Around. What are the data loss risks associated with Write-Back?
Mid
Explain the 'Dual Write' problem. How do you ensure the cache and database don't get out of sync during an update?
Senior
Why might you prefer moving caching logic into a library or sidecar (Read-Through) rather than handling it manually in your application code?
Senior
In a cache-aside pattern, on a write should you update the cache or delete (invalidate) the entry? Why is deleting often safer?
Senior
Eviction Policies
What happens to a cache when it reaches its memory limit but no TTLs have expired yet?
Junior
Compare Least Recently Used (LRU) and Least Frequently Used (LFU). In what specific traffic pattern would LFU outperform LRU?
Mid
How would you define and measure a 'Cache Hit Ratio'? What does a high hit ratio with high latency suggest about your cache design?
Mid
Explain the trade-off between memory usage and hit ratio when sizing a cache.
Mid
If your cache is primarily storing user session data that expires after 30 minutes of inactivity, which eviction policy would you configure and why?
Mid
When would Most Recently Used (MRU) eviction outperform LRU?
Mid
What is a 'healthy' cache hit ratio, and if your ratio is low, what specific architectural issues or traffic patterns would you investigate?
Senior
Explain the concept of the 'Clock' or 'Second Chance' eviction policy. How does it approximate LRU with less overhead?
Senior
What is the 'Belady's Anomaly' in the context of FIFO cache eviction?
Senior
How does an ARC (Adaptive Replacement Cache) attempt to improve upon standard LRU?
Senior
What is the 'Two-Segment' or 'LRU-K' algorithm, and why might it be better than standard LRU for certain workloads?
Senior
HTTP Caching
What happens to a cached resource when a 'Conditional GET' (If-None-Match) returns a 304 Not Modified?
Junior
Explain the Cache-Control: no-cache vs. no-store directives. Which one allows the browser to keep a copy?
Mid
What is the purpose of the Vary HTTP header in caching, and how does it prevent a mobile user from receiving a cached desktop version of a page?
Mid
How do ETags work to facilitate conditional GET requests, and how does this save bandwidth?
Mid
Explain the public vs. private directives in Cache-Control. Why is this distinction critical for security when caching authenticated responses?
Mid
What is the difference between the ETag and Last-Modified headers?
Mid
Explain the difference between freshness (Cache-Control/Expires) and validation (ETag/Last-Modified) in HTTP caching. When does a browser send a Conditional GET?
Mid
What is the difference between 'Strong Validation' (ETags) and 'Weak Validation' in HTTP caching?
Senior
TTL & Expiration
How does a sliding TTL differ from a fixed TTL?
Junior
Explain the Stale-While-Revalidate pattern. How does it improve user-perceived latency while still ensuring data eventually becomes fresh?
Mid
What is the purpose of cache warming or pre-warming, and when is it necessary to do this before a deployment or high-traffic event?
Mid
What is the difference between evicting data based on a Time-To-Live (TTL) versus evicting based on memory pressure (Max-Memory), and can a key be evicted before its TTL expires?
Mid
How do you determine the optimal TTL (Time-to-Live) for a specific piece of data?
Mid
What is the difference between active (eager) expiration and lazy (passive) expiration of TTL'd entries, and what are the trade-offs?
Mid
What is the difference between explicit (event-based) invalidation and time-based (TTL) expiration, and when would you combine them?
Mid
What is 'Refresh-Ahead' caching, and how does it help in reducing tail latency?
Senior
Cache Failure Modes
What is Cache Penetration, how does it differ from a standard cache miss, and why is negative caching or a bloom filter used to solve it?
Mid
Explain the Cache Avalanche scenario. How can jitter (adding randomness to TTLs) prevent a database from crashing during a mass expiration event?
Mid
Explain the difference between 'Cache Penetration' and 'Cache Avalanche'. How do their mitigations differ?
Mid
How does 'Negative Caching' help protect your downstream database?
Mid
What is a Cache Stampede, and how does request coalescing or locking prevent multiple concurrent requests from recomputing the same expensive value?
Senior
How do you identify and handle a hot key (a single key receiving disproportionately high traffic) in a distributed cache to prevent a single node from becoming a bottleneck?
Senior
What is the difference between a cache avalanche and a cache stampede?
Senior
How does a Bloom filter actually work, and why are false positives (but not false negatives) acceptable when using it to guard a cache?
Senior
Distributed Caching
What is the difference between an In-Process (Local) cache and a Distributed (Remote) cache? When would you choose one over the other?
Junior
How does consistent hashing minimize cache misses when adding or removing a node from a distributed cache cluster?
Mid
What is Consistent Hashing, and why is it preferred over simple 'mod N' hashing for distributing cache keys across a cluster?
Mid
Explain the difference between sharding (partitioning) and replication in a cache cluster. Which one helps with read throughput, and which one helps with storage capacity?
Mid
From a high-level architectural perspective, why might you choose Redis over Memcached (or vice-versa) for a caching layer?
Mid
What is 'Multi-level Caching' (L1/L2 application caches), and how do you manage the complexity of multiple layers?
Senior
What is 'Near Caching' and how does it leverage both local and distributed layers?
Senior
In a distributed system, how do you ensure cache coherence across different geographical regions?
Senior
Invalidation & Consistency
What is the 'Cache Invalidation' problem, and why is it considered one of the 'two hard things' in computer science?
Mid
How does using a versioned key (e.g., user:v2:123) help with cache invalidation during a schema change or deployment?
Mid
What is the difference between Strong Consistency and Eventual Consistency in a multi-node cache cluster?
Mid
Explain the concept of 'Eventual Consistency' in the context of a cache-aside pattern.
Mid
Explain the 'Cache Coherence' problem when using local caches across multiple application instances.
Senior
If your system requires strong consistency, can you still use a cache, and what are the trade-offs in latency if you do?
Senior
How do you propagate cache invalidation across multiple distributed cache nodes or application instances (e.g., via pub/sub or broadcast messages)?
Senior
Top 68 Caching Interview Questions And Answers 2025 | TechPrep