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
47 practiced

You're given a small code snippet (pseudocode) that implements cache-aside: if cache miss then read DB and write cache. Under concurrent requests, multiple processes perform the DB read and write cache simultaneously, causing unnecessary DB load. Show a concrete concurrency bug example and propose fixes (per-key locking, request coalescing, or early recompute). Explain trade-offs.

MediumTechnical
43 practiced

Explain how to establish performance budgets for API latency and page load (e.g., target TTFB and p95 response time). Describe how caching decisions and instrumentation map to these budgets and propose a short roadmap of caching interventions to meet a 200ms p95 TTFB SLO.

HardTechnical
43 practiced

Compare and analyze the trade-offs of performing personalization at the edge using edge functions (e.g., Cloudflare Workers, Lambda@Edge) vs performing personalization server-side and delivering fully personalized HTML. Consider latency, cacheability, operational complexity, and data privacy.

MediumTechnical
48 practiced

Design an observability/telemetry stack specifically for caching: what logs, metrics, traces and sampling strategy would you collect? Include examples of key dashboard panels (hit/miss heatmap, per-key latency percentiles, eviction trends) and how you'd use traces to root-cause tail latency that appears in cached requests.

HardTechnical
48 practiced

Describe and design an implementation of stale-while-revalidate (SWReval) across CDN and origin caches. Explain how you would implement it end-to-end, how you prevent a stampede of revalidations, and how you ensure origin doesn't get overloaded during large-scale revalidation events.

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.