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.
Describe how common HTTP caching headers (Cache-Control, ETag, Last-Modified, Expires) affect caching behavior in a mobile app. Provide example header values and explain how a mobile client should handle conditional GETs (If-None-Match, If-Modified-Since) and 304 Not Modified responses to minimize data transfer.
Given strict memory constraints on low-end devices, describe a decision framework for which resources to cache on-device (images, API responses, computed state). Include factors like fetch cost, frequency of access, size, privacy, and user-perceived latency. Provide an example prioritization for a news app.
As a mobile backend decision, explain the practical differences between Redis and Memcached. Highlight aspects important for mobile applications such as persistence, data structures, advanced operations (sorted sets), replication, and memory footprint. Give example cases where one is preferable over the other.
For a GraphQL backend with expensive computed fields (e.g., recommendation score), design caching semantics that minimize recomputation while avoiding stale values. Propose server-side cache keys, dependency tracking, invalidation on dependent data changes, and client-side hints so mobile apps can request cached-but-valid data or force recompute when needed.
Design an encrypted on-device cache for mobile that supports secure key rotation. The solution must allow offline access, use platform keystores, enable rotating encryption keys without losing access to cached data, and prevent attackers from extracting cached secrets. Describe key-wrapping/envelope-encryption and a migration plan for rotation.
Unlock Full Question Bank
Get access to all 36 Caching Strategies & In-Memory Optimization interview questions and detailed answers.
Sign in to ContinueJoin thousands of developers preparing for their dream job.