Caching interview questions
Practice 10 questions on caching. Each runs in a real in-browser editor with Jest tests and a worked, diagram-backed solution.
10 questions
- EASY
Sliding TTL Cache
Implement a cache whose entries expire a fixed time after their last access, not after being set.
15 minJavaScript - MEDIUM
Async Memoize with TTL
Implement an async memoize that caches results by key for a TTL and coalesces concurrent calls for the same key.
25 minJavaScript - MEDIUM
ETag Revalidation Cache
Cache responses by URL and revalidate with an ETag, reusing cached data on a 304 Not Modified.
25 minJavaScript - MEDIUM
Idempotency Key Queue
Dedupe by idempotency key: run a task at most once per key, cache the result with a TTL, and retry on failure.
35 minJavaScript - MEDIUM
Normalized Entity Cache
Store entities flat by id, normalizing nested relations and merging updates immutably.
25 minJavaScript - MEDIUM
Singleflight
Implement singleflight so concurrent calls for the same key share one in-flight promise instead of duplicating work.
25 minJavaScript - MEDIUM
Stale-While-Revalidate Cache
PREMIUMReturn cached data instantly, serving stale values while revalidating them in the background.
25 minJavaScript - HARD
DataLoader
PREMIUMBatch and cache load(key) calls made in one tick into a single batch function call, preserving order.
40 minJavaScript - HARD
Mini React Query Core
PREMIUMBuild a framework-agnostic query cache with request dedup, staleTime, subscribers, and invalidation.
40 minJavaScript - HARD
Realtime Search with Cache
PREMIUMBuild a search box that caches results per query and dedupes in-flight requests.
40 minUI / FrameworksAngularReactHTML / CSS / JSVue