Interview Q&A · questions with model answers
Caching Interview Questions
Part of the study plan for: Backend Engineer · Full Stack Engineer
Ordered by how often they're asked. Most-asked answers are free to read in full; members see every answer and can rate their confidence on each.
-
Most asked What is a cache stampede (thundering herd) and how do you prevent it?
A stampede happens when a popular key expires and many concurrent requests miss at once, all hitting the database to recompute the same value, which can overload it. Prevent it with request…
-
Most asked What are the risks of caching personalized or authorized data?
If cache keys or HTTP caching rules don't include the user, tenant or permissions, one user's data can be served to another, a serious data leak. CDNs caching authenticated responses are a common…
-
What are cache eviction policies (LRU, LFU, TTL) and how do you choose?
When memory is full, LRU evicts the least recently used keys, LFU evicts the least frequently used, and TTL-based expiry removes keys after a set time. LRU suits most workloads; LFU protects…
-
What are the different layers where you can cache in a web system?
Browser cache, CDN/edge cache, reverse proxy (Nginx/Varnish), application in-process memory, distributed cache (Redis), database buffer/query caches, and precomputed results (materialized views,…
-
What are the risks of write-behind caching?
Data acknowledged by the cache but not yet flushed is lost if the cache loses it (restart, failover, flush crash); and the database lags the cache. Use it only for loss-tolerant data with durable,…
-
What must a cache key include for an API response in a multi-tenant app?
Every input that changes the response: tenant, resource, role/permission set (if it changes the data), locale, relevant feature flags and a schema version — or cache permission-independent data and…
-
What is negative caching and why is it useful?
Negative caching stores 'not found' results (briefly) so repeated lookups for missing keys don't hit the database, protecting against both legitimate repeated misses and cache-penetration attacks…
-
What is cache warming and when is it needed?
Cache warming preloads frequently used data before traffic arrives (after deploys, failovers or cache flushes) so the first users don't suffer misses and the database isn't hit by a burst.