Lesson 7 of 30
HTTP caching decides whether the browser re-downloads a response. Application-level cache design decides something different — what a fetched value means, when it's stale, and what a mutation should invalidate.
14 min read
Every option explains itself — why the right one is right, and why each wrong one is wrong. Miss one and it comes back later on a spaced-repetition schedule.
Question 1 of 3
A product appears on both a product page and a search results list, each fetched by a separate query in a per-query cache. A mutation updates the product's price via the product page's query. What happens to the copy shown in search results?
Hints without spoilers, and a plain explanation of why a wrong answer was wrong — answered only from this lesson. Free account, no card.
Sign up freeWhat interviewers actually ask about this, and what a strong answer has to cover.
A strong answer covers
Likely follow-ups
This is the design layer above HTTP: the kind of cache a data-fetching library like React Query or Apollo builds on top of, not the Cache-Control/ETag mechanics that decide whether a byte stream gets re-downloaded. Three design questions define it:
["orders", { status: "open", page: 2 }] is a different cache entry from ["orders", { status: "closed" }], even though both fetch "orders").The same product appears in two places: a product-page query and a search-results query.
Say a product page and a search results list both display the same product. A per-query cache stores each fetch's result independently — the product-page query and the search-results query each hold their own copy of that product's data. It's simple to build, but when a mutation updates the product's price, only the query that mutation directly targeted gets refreshed; the other cached copy quietly goes stale until it's separately refetched. A normalized cache stores the product entity once, keyed by its id, with every query that references it pointing at that one shared copy — updating the price in one place updates every screen showing that product automatically, because there's only one copy to update.
Cache-Control/ETag behavior and still show stale, inconsistent data on screen if the application-level cache's invalidation strategy is wrong — they solve different problems."How would you design the caching layer for a data-fetching library, or for this specific feature's fetched data?" is a real system design prompt, and the strong answers separate cache key design, invalidation, and staleness tolerance as three distinct decisions rather than treating "caching" as one monolithic checkbox.