Caching at Every Layer
Follow one request from the browser outward through every cache it can hit — the HTTP cache (Cache-Control, ETag, Last-Modified, revalidation), the CDN edge, the client query cache (React Query / SWR), and server-side memoization — then face the hard part: invalidation. Covers strong vs. weak validators, stale-while-revalidate, cache stampedes and request coalescing, negative caching, and cache keys. Every explanation proves its answer against the relevant RFC.
Questions
- Not answered. Who coined the "two hard things in Computer Science" quip?
- Not answered. What does
Cache-Control: no-cacheactually permit? - Not answered. When does
no-storebelong on a response? - Not answered. What does
Cache-Control: privatetell caches? - Not answered. Why is the CDN serving one user's data to everyone, and what's the fix?
- Not answered. How long does each cache treat this response as fresh?
- Not answered. Which numeric HTTP status lets the cache reuse its copy without re-sending the body?
- Not answered. Which constraint does a correct
304 Not Modifiedresponse obey? - Not answered. When a cache revalidates a stored GET response, which header pairing does it use?
- Not answered. What does the
W/prefix on an ETag signify? - Not answered. Why must a range request's validator be a strong ETag, not a weak one?
- Not answered. Why can
Last-Modified(without anETag) serve a stale body even though revalidation "succeeded"? - Not answered. Which directive lets a cache return a stale response immediately while it revalidates in the background?
- Not answered. What does the user experience 700 seconds after the response was stored?
- Not answered. Which directive lets a cache keep serving a stale copy when revalidation fails (origin error or unreachable)?
- Not answered. What is the practical effect of adding
must-revalidatetomax-age=60? - Not answered. What does
immutableadd over the year-longmax-agealone? - Not answered. For how many hours will a cache treat this response as fresh?
- Not answered. What does
Vary: Accept-Encodinginstruct caches to do? - Not answered. What's the likely consequence of adding
Vary: User-Agentto shared, cacheable HTML? - Not answered. What does
Age: 550tell you? - Not answered. Which responses should a shared CDN cache refuse to store by default?
- Not answered. What is the "stampede" that follows a hot key's expiry?
- Not answered. Which techniques genuinely mitigate a cache stampede on a hot key?
- Not answered. What is this
404-caching technique called, and what is its main risk? - Not answered. With request coalescing enabled, how many requests reach the origin?
- Not answered. What's the difference between
staleTimeandgcTimein React Query? - Not answered. Why does React Query refetch data it just rendered?
- Not answered. What happens when two components call
useSWR('/api/user')within ~2 seconds? - Not answered. Why does fingerprinting make cache invalidation almost a non-problem?