TECHNOLOGY

Stop shared caches from mixing authenticated responses

In this article
THE QUICK TAKE

Authorize storage and reuse explicitly for authenticated responses; a collision-resistant key is insufficient by itself.

Two authorized clients request the same resource URL but are entitled to different model metadata. After a shared cache is enabled, one receives the other’s representation. The defect is an access boundary failure even if both responses are syntactically valid JSON. Audit authenticated-response storage rules before using cache hit rate as an optimization target.

Define the resource’s privacy

Determine whether the response is public, principal-specific or tenant-specific. A catalog can reveal allowed models, internal route names or account limits without containing a prompt. A generated result can contain more sensitive content. Document the intended audience for each resource rather than assuming GET means public. The HTTP method describes operation semantics; it does not classify the returned information’s confidentiality.

Read the storage policy completely

Authenticated requests have specific shared-cache restrictions, and response directives can change the applicable behavior. Distinguish forbidding storage from requiring revalidation before reuse. A directive that permits private storage is not the same as permission for a shared gateway. Inspect the actual headers produced by the origin and those received after intermediaries. A configuration comment expressing intent cannot compensate for a response that authorizes broader caching in practice.

Do not rely on a guessed cache key

Including an authorization-related field in a key can reduce collisions, but it does not independently establish that storage is allowed. Raw credentials in cache-key logs introduce another exposure. Prefer a design with explicit authorization-aware isolation and minimal diagnostic data. If a trusted proxy derives an internal tenant identity, verify how that identity is created and whether clients can supply or override it. An untrusted incoming header must not choose another tenant’s cached response.

Test identities in both directions

Use synthetic accounts with intentionally different permitted metadata. Prime the cache under the first identity, query under the second and then reverse the order. Include logout or credential rotation where it changes the access context. Confirm that an unauthorized client never receives a stored authorized response. Also test a request without credentials, because the public path may use a different cache rule from the authenticated path.

A cache test should compare authorization-relevant fields, not merely hashes that differ for unrelated timestamps. Select synthetic entitlements with visibly different permitted model sets. This makes a cross-principal reuse failure unambiguous while avoiding real account details or private generated content in the evidence.

Preserve a measurable correctness condition

The acceptance criterion is that every returned representation is authorized for its requesting context under the origin’s current policy. Cache hits are useful only after that condition holds. Revalidation must still send the appropriate identity, and invalidation must follow changes that revoke access where the application requires it. A successful test on one URL does not establish isolation for all resources. Keep the tested resource class, cache layer and credential boundary explicit in the report, and retain only redacted evidence needed to reproduce a failure.

Primary references

HTTP Caching. Defines shared-cache handling of authenticated responses and cache-control directives.

HTTP Semantics. Defines authorization-related request context and response semantics.

Problem Details for HTTP APIs. Supports explicit access-denial errors instead of exposing a cached private representation.

Related reading: Inference API telemetry without default prompt capture; Fetching the OpenRouter model catalog before deployment.

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