awesome-everything RU
↑ Back to the climb

Caching

SWR: multiple-choice review

Crux Multiple-choice synthesis across the SWR unit — the two windows, single-flight, stale-if-error, client revalidation, and the auth hazard.
Your altitude — climbing toward senior
ZeroJuniorMiddleSenior
You are at senior altitude — in orbit
◷ 13 min

Six questions that cut across the whole unit. Each mirrors a header you write or an incident you triage — not a directive to memorise, but a freshness-versus-latency trade to weigh under real traffic.

Goal

Confirm you can connect the freshness window, the SWR window, stale-if-error, single-flight, and the client revalidation model — and that you know the one place SWR must never go.

Quiz

A request arrives 90 seconds after caching, with Cache-Control: max-age=60, stale-while-revalidate=300. What does the user get and why?

Quiz

Why does max-age alone produce a per-TTL p99 sawtooth, and how does stale-while-revalidate flatten it?

Quiz

A popular key expires under 10k req/s and the edge fires one background revalidation per stale-hit. What breaks and what is the fix?

Quiz

What does stale-if-error add on top of stale-while-revalidate, and why is pairing them the senior default?

Quiz

Two components call useSWR('/api/user') in the same render tick. What does the SWR client library do, and what governs it?

Quiz

For which response is stale-while-revalidate the wrong tool, and why?

Recap

The through-line is one contract: return what you have now, fetch what is correct next, never block the human on the refresh. max-age sets freshness, the SWR window kills the synchronous-revalidation sawtooth, stale-if-error turns an outage into degraded-but-up, single-flight plus jitter stops the background-refresh herd, and the client libraries reproduce the same model with dedupingInterval and focus/reconnect revalidation. The one hard boundary: never apply SWR to auth, permissions, or anything where stale data is a security bug.

Continue the climb ↑SWR: free-recall review
shortcuts expand
search
K
prev piece
k
next piece
j
cycle tier
t
this menu
?
sources3
expand
  1. 01
  2. 02
  3. 03

Trademarks belong to their respective owners. Editorial reference only.