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.

MediumTechnical
51 practiced

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.

MediumTechnical
43 practiced

Design and implement (pseudocode is fine) an image caching strategy for a React Native app that combines a memory cache and a disk cache. Include behavior for cache size limits, eviction, image resizing/decoding off the UI thread, prefetching, and how to fall back to native image loaders (Glide/Picasso on Android or SDWebImage on iOS) when available.

MediumTechnical
42 practiced

Explain how ETag-based validation works end-to-end in a mobile client. Describe how you would persist and associate ETag values with cached resources on device, how to handle servers that do not support ETag (fallback approaches), and how to avoid unnecessary re-downloads when resources are large.

MediumTechnical
60 practiced

Write a custom OkHttp Interceptor (pseudocode or Kotlin) for Android that implements offline-first behavior: when offline serve cached responses up to a configuration-staleness (e.g., max-stale 7 days); when online prefer fresh responses but fall back to cache on failure. Include cache-control header adjustments.

MediumTechnical
44 practiced

Explain how a normalized GraphQL client cache works (e.g., Apollo normalized cache). Describe how entity normalization helps cache hits across queries, and what additional steps you must take to support offline sync, conflict resolution, and cache eviction in a mobile GraphQL client.

Unlock Full Question Bank

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

Sign in to Continue

Join thousands of developers preparing for their dream job.