Caching and conditional requests
Vary, CDNs and cache keys
Wrong cache keys can serve the wrong representation.
Understand the concept
Cache keys can include method, query handling and selected fields, not merely URLs. Vary separates request-header-dependent representations. If a site selects language through a cookie, varying only by Accept-Language does not encode that choice.
Design authentication and cookie isolation before shared caching. Keying on every cookie can create excessive cardinality; sometimes not caching is correct. Authenticated shared-cache reuse has special rules and should not be overridden casually.
Query normalisation must preserve semantics. Purges, TTLs and deployment invalidation differ. A HIT does not prove correct content: test users, languages and origins. Keep intermediary and application assumptions aligned to prevent cache-key mismatches.
Maintain correctness in bilingual CDN delivery.
Equating a CDN HIT with correct caching.
One topic. Three levels of depth.
Vary: Accept-EncodingSeparates encoding variants.
This page does not send requests to external servers. Messages are readable HTTP/1.1 illustrations, not HTTP/2 or HTTP/3 wire dumps. example.test is reserved for examples. Run commands and JavaScript only in your own test environment; never publish real tokens or cookies.
Try it yourself first.
Does Vary: Accept-Language cover language chosen by cookie?
Show the solution and explanation
Cache key must reflect actual selection inputsNo; design for the actual selection input or use private/no-store policy.