TECHNOLOGY

HTTP Vary and authenticated caching: a cache key is not an access policy

In this article
THE QUICK TAKE

Vary describes representation selection; deciding whether an authenticated response may be stored and reused requires a separate cache policy.

One URL can produce different representations

A model catalog endpoint may vary by a caller’s permitted models, selected language or requested representation. Caching only by URL can therefore associate one response with requests that should receive a different result.

Vary identifies request-header dimensions that influenced representation selection. It helps a compatible cache distinguish variants, but it does not decide whether a response is appropriate for shared storage in the first place. Variant selection and permission to reuse need separate interpretation.

Authenticated requests have specific shared-cache rules

The HTTP caching specification restricts reuse of responses to requests carrying Authorization unless a response directive explicitly permits shared caching under its requirements. Authentication is therefore relevant to storage and reuse, not merely another optional string to append to a cache key.

A proposed review identifies whether the endpoint returns public information or caller-specific data. Public cache directives must not be introduced casually to improve hit rates on a personalized endpoint. Correctly separating variants does not replace a deliberate decision about where the information may be retained.

Vary does not replace private or no-store policy

A response can require separation by language while still being unsuitable for shared reuse. Conversely, a public representation may legitimately vary by encoding or media type. The cache policy and variation dimensions describe different properties of that response.

Do not treat a Vary declaration as an instruction to store every variant. Nor should a generic gateway remove an existing variation dimension while adding its own. An apparently harmless header rewrite can merge responses whose body selection depended on information no longer represented in the cache’s matching rules.

Intermediary configuration can change the result

Cloudflare’s origin-cache-control documentation shows behavior differences depending on its configuration, including handling of authenticated requests and cache directives. This is evidence that an intermediary’s product settings matter in addition to an origin’s intended policy.

A client cannot infer deployed behavior merely from the presence of one familiar header. A proposed deployment review checks the relevant cache rules, overrides and actual response path. Documentation about a product default is not proof of the settings on a particular application.

Review isolation using non-sensitive fixtures

A proposed check uses harmless distinct fixtures for different authorization contexts and representation preferences. It verifies which variants may be reused and whether a later request receives its own expected representation. The check should avoid real private content.

This article concerns HTTP response caching, not permission to retain inference content. A clear contract keeps variation, storage permission, freshness and caller isolation separate rather than assuming that one cache-key adjustment establishes all of them.

Primary references

HTTP authenticated cache rules.

Vary response-header semantics.

Cloudflare origin-cache-control behavior.

Related explanations: HTTP request boundaries; Operation context.

Earn rental income from GPUs

Have idle GPUs or looking to fund AI infrastructure? Retrivium finds a rental platform, sets up the server and helps you assess income and costs with a pilot.

Explore GPU hosting
← All articles