InterviewStack.io LogoInterviewStack.io

Caching and Performance Optimization Questions

Covers design and implementation of multi layer caching and end to end performance strategies for web and backend systems. Topics include client side techniques such as browser caching, service worker strategies, code splitting, and lazy loading for components images and data; edge and distribution techniques such as content delivery network design and caching of static assets; and server side and data layer caching using in memory stores such as Redis and Memcached, query result caching, and database caching patterns. Includes cache invalidation and coherence strategies such as time to live, least recently used eviction, cache aside, write through and write behind, and prevention of cache stampedes. Covers when to introduce caching and when not to, performance and consistency trade offs, connection pooling, monitoring and metrics, establishing performance budgets, and operational considerations such as cache warm up and invalidation during deploys. Also addresses higher level concerns including search engine optimization implications and server side rendering trade offs, and how performance decisions map to user experience and business metrics at senior levels.

MediumTechnical
28 practiced
Design rules for edge cache key composition when requests include query strings and cookies. For example, search endpoints accept ?q= and pagination ?page=, while cookies include session info. Explain which query params should be part of the cache key, how to canonicalize and normalize query strings, how to deal with ordering and irrelevant tracking params, and how to ensure personalization doesn't leak between users.
EasyTechnical
36 practiced
Explain TTL (time to live) and LRU (least recently used) eviction. How do TTL and LRU interact when both are configured on a cache instance? Provide a simple example of configuring TTL and LRU in Redis or Memcached and explain how each affects hit rate under memory pressure.
HardTechnical
35 practiced
You must prevent a cache stampede on a computationally expensive key at 10k QPS. Design and provide pseudocode for a distributed request coalescing (singleflight) mechanism that deduplicates concurrent fetches across processes using Redis. Ensure it supports timeouts and failure paths where waiting clients receive a fallback or stale data.
MediumTechnical
30 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.
HardTechnical
32 practiced
Analyze memory fragmentation and eviction tuning for Redis when storing many large objects of varying size. Discuss maxmemory-policy choices, memory-fragmentation-ratio, lazyfree-lazy-eviction, active defragmentation, impact of large-key eviction on latency, and recommendations to minimize OOMs and outage risk.

Unlock Full Question Bank

Get access to hundreds of Caching and Performance Optimization interview questions and detailed answers.

Sign in to Continue

Join thousands of developers preparing for their dream job.