Code Room
System designMediumsd-g064
Subject Cache invalidationLevel Mid–Senior~35 minCommon in Distributed systems interviewsIndustries Technology, Software development

Question

Design the TTL and revalidation strategy for an API response cache in front of a slow, occasionally-flaky upstream (a 300ms third-party API that sometimes errors or times out). You want most responses served instantly from cache, freshness within ~60s, and — importantly — you'd rather serve slightly stale data than show users an error when the upstream is down. Design the caching/revalidation behavior to balance freshness, latency, and resilience.

What a strong answer looks like

Clarify scale and constraints first. Propose a clean component breakdown, then go deep on the hard parts — data model, bottlenecks, consistency, failure modes — and name the trade-offs you are making.

Narrate your design
Loading whiteboard…
Run or narrate your approach, then ask the coach.