Caching
59 bites tagged Caching — interview questions with model answers, and 60-second explainers.
Consistent A/B bucketing across sessions and devices
Hash a stable user ID with experiment salt, not random or cookie-only; beware caches keyed without variant. Deterministic, identity-based bucketing.
Optimizing Slow iOS CI Build Times
Profile the build, cache CocoaPods and DerivedData, use prebuilt frameworks, parallelize, scope to changed work. CI build optimization. buying faster runners without measuring the bottleneck first.
Apollo's normalized cache
Apollo flattens query results into entities keyed by type plus id, so one object is stored once and shared, updating everywhere at once. understanding GraphQL client caching.
Capacity planning for a distributed cache
Track hit ratio, memory and eviction rate, throughput/latency, and connections; correlate with growth to forecast when to add capacity before the hit ratio or evictions… Whether you can pick the right cache metrics and forecast scaling.
Design a simple chaos experiment for a cache dependency?
Hypothesis that the service degrades gracefully when Redis is unavailable, monitor error rate, latency, DB load, and cache hit rate. Applying chaos thinking to a cache.
Automating a recurring manual cache clear
Recognize the repetitive manual task, document the runbook, then automate it into the deploy pipeline as a post-deploy hook with monitoring. Eliminating toil.
Designing a cache health dashboard
Hit ratio, latency, memory and evictions, connections and saturation, with stat panels for current state and time-series for trends. knowing which cache signals matter and matching them to visualizations.
Diagnosing high Redis eviction and cache misses
Use INFO memory and stats to confirm pressure, check fragmentation ratio, pick LFU over LRU for skewed access, set sane TTLs. practical Redis memory debugging. just raising maxmemory without finding the cause.
The buffer pool's role in database IO
Caches pages, serves reads from RAM, buffers dirty writes flushed later, uses eviction like LRU. in-memory page caching of disk data.
Cache-aside pattern pros and cons
App reads cache, on miss loads DB and populates, invalidates on write; pros are resilience and lean cache, cons are stale windows and app-managed invalidation. knowing lazy-loading caching and its consistency cost.
Cache-aside pattern with Redis and RDS
App checks cache, on miss reads DB and populates, writes invalidate the key, and consistency is eventual. knowing the lazy-loading cache pattern and its costs.
How does caching reduce database load?
Cache-aside reads, RAM-speed lookups, TTL plus invalidation. caching as a read-offload layer. treating the cache as durable source of truth or ignoring stale-data and invalidation.
CDN caching for static and dynamic content
Cache static assets with long TTLs and versioned filenames; bypass or short-cache dynamic per-user responses; invalidate via fingerprinted URLs not purges. CDN cache behavior and invalidation.
Reducing cross-region image pull costs
A per-region pull-through cache or geo-replicated registry serves pulls locally, cutting latency and egress, traded against consistency lag, storage cost, and cache management. registry topology for multi-region pulls.
Describe a Nuxt server caching strategy for slow upstream APIs
Tests server-side caching architecture in Nuxt Nitro. A strong answer proposes a server middleware or route handler with Redis or LRU in-memory cache, sets TTL per endpoint, and handles cache invalidation.
How would you cache data between a list and detail view?
Use nested keys so detail reads from list cache with staleTime to skip refetches. Splitting server and client state, sharing cache from list to detail.
Apollo Client: GraphQL as Reactive State
Apollo Client turns your GraphQL API into reactive state that components read like a local cache. It shines when multiple views share overlapping data, but teams often footgun by sending one massive query instead of letting the cache normalize fragments.
Design a Service Worker caching strategy for a news app
Cache First for the app shell, Stale-While-Revalidate for static assets, and Network First for article APIs. Matching resources to caching patterns and justifying speed vs freshness. One strategy everywhere or ignoring cache quotas.
Explain Network First vs Cache First caching and when to use each
Tests matching caching strategy to asset freshness. Cache First serves static assets from the Cache API, falling back to network. Network First fetches fresh content, falling back to cache offline.
What is a Service Worker's role and key PWA capability?
Tests understanding of the Service Worker as a network proxy and its core PWA benefit. A strong answer states it intercepts requests as a proxy and enables offline use via granular caching. Red flag: confusing it with Web Workers or DOM manipulation.
How would you design auth for ISR pages without losing cache benefits?
Tests cache segmentation and dynamic boundaries in Next.js. Propose a static ISR shell for anonymous users, then fetch personalized data client-side or via dynamic server paths when cookies are present.
Implement A/B testing with Middleware rewrites and cookies
Sticky cookie, internal rewrite, vary cache on cookie, server-side analytics. Using Next.js Middleware to split traffic and the cache or analytics impact. Client redirects or ignoring cache collisions.
How do you opt out of static rendering for real-time data?
Tests Next.js App Router caching and dynamic rendering escape hatches. Cover force-dynamic SSR, ISR with revalidate, noStore, and client fetching; weigh server load vs staleness. Red flag: only CDN purges without segment config or data cache fixes.
Full Route Cache vs Data Cache and per-fetch cache control
Tests App Router's dual caching layers. Full Route Cache stores rendered HTML and RSC payload at build time; Data Cache stores raw fetch results across routes. Control a fetch with cache and next.revalidate options.
Get Caching bites daily.
Five a day, five minutes, offline. With quizzes so it sticks.
Open testing — you’ll join as an early tester.