Caching Strategies & In-Memory Optimization Questions

Designing cache layers to cut redundant work and speed up reads, and the correctness costs that come with them. Covers cache placement across client, CDN, application, and in-memory store tiers, including platform-specific caching on mobile (in-memory and disk caches on iOS and Android, secure on-device token storage) and in the browser (localStorage, IndexedDB, Service Workers). Covers eviction policies, TTLs, write-through vs write-back, warming, and invalidation, plus cache stampede and thundering-herd mitigation when a hot key expires under load. Also covers using an in-memory store like Redis directly rather than only as a cache: distributed locks, counters, rate limiters, and leaderboards. Includes distributed and sharded cache architecture (replication, failover, sizing, migration) and the operational side of running one: health monitoring, alerting, and incident runbooks, plus the security and privacy risks caching introduces, such as cache poisoning and caching PII across shared tenants. Emphasizes hit-rate reasoning and the staleness/consistency trade-offs caching introduces.

HardTechnical
43 practiced

Plan an A/B experiment to quantify the impact of enabling edge caching (stale-while-revalidate) on checkout conversion. Define metrics, hypothesis, sample size considerations, experiment duration, instrumentation, significance tests, and safeguards (e.g., kill switch). Discuss how to isolate caching effects from confounders like traffic source or client geography.

HardTechnical
58 practiced

You have 100 million keys in Redis, each holding roughly 1KB of JSON, and memory pressure is causing frequent evictions. How would you go about shrinking the footprint without just buying more memory, and what would you weigh in choosing between the options you come up with?

MediumTechnical
44 practiced

You need to choose a session store for a globally distributed web app: local in-memory per-process cache, Memcached, or Redis. Compare them across latency, shared access across instances, failover and replication, secure handling of session data, and operational complexity. Recommend the best approach for scalable sessions and justify your choice.

MediumTechnical
42 practiced

In JavaScript, write a concise Service Worker fetch handler that implements a 'stale-while-revalidate' strategy for images: return cached image if present, kick off a background fetch to update the cache, and on cache miss fetch from network and store in cache. Use async/await, Cache API, and include a cache name constant and a TTL comment.

EasyTechnical
44 practiced

Compare localStorage, sessionStorage, cookies, and IndexedDB for client-side caching. For each API list ideal use-cases, approximate size limits, persistence characteristics, and key security considerations for storing cached data.

Unlock Full Question Bank

Get access to all Caching Strategies & In-Memory Optimization interview questions and detailed answers.

Sign in to Continue

Join thousands of developers preparing for their dream job.