﻿# Vary model-catalog caches by representation headers

Vary identifies request fields used for representation selection; freshness and access rules remain separate.

Author: Retrivium editorial team
Updated: 2026-11-03
Canonical URL: https://retrivium.ai/journal/guide-http-vary-catalog/
Language: en

A public catalog endpoint returns a compact representation to one client and a richer representation to another. After a cache is introduced, clients occasionally receive the wrong variant. The model list itself may be correct; the cache lookup may simply ignore a request header that influenced the selected representation.

## Identify the selecting headers

Start with the origin's actual selection rules. Media-type preference, content coding or locale can change a catalog response, but only if the endpoint implements that behavior. Do not invent variation dimensions from every incoming header. Record a pair of requests that differs in one selecting field and compare the response metadata and body. This establishes whether the requests truly address different representations of the same resource.

## Understand what Vary contributes

The `Vary` response field names request fields that a cache must consider when deciding whether a stored response can satisfy another request. It does not change the URL, authenticate a user or establish a retention period. A representation can have a correct variation key and still be stale. Keep freshness directives and validators alongside the selection rule, and avoid treating the presence of Vary as a complete cache policy.

## Test both warm-cache directions

Prime the cache with the compact variant, request the rich variant, and then reverse the order with a clean test key or isolated cache. Compare the origin and cached responses using synthetic clients. Testing only a miss followed by an identical request cannot expose variant mixing. Preserve request fields as the cache received them, because a gateway can normalize or remove them before selection. Also check the encoding of the returned bytes before comparing documents.

## Keep authorization out of guesswork

A private catalog may reveal models or routes available to a particular principal. Merely varying on an authorization-related field is not a substitute for the storage rules governing authenticated responses. Decide explicitly whether shared storage is permitted. Avoid placing raw credentials in diagnostic cache-key logs. If a tenant boundary changes the result, document its application-level isolation rather than assuming an ordinary public catalog recipe applies unchanged.

A response can vary in encoding while its parsed catalog entries remain identical. Compare the representation metadata as well as the logical model list. Otherwise a test may miss a compressed variant being delivered with the wrong coding header, a problem that appears only in consumers with different decoder behavior.

## Resolve the source of disagreement

When the origin varies correctly but the cache does not, inspect the cache implementation and its configured header allowlist. When the origin omits Vary despite selecting different representations, correct the origin's metadata first. If the difference comes from asynchronous catalog updates rather than representation selection, investigate freshness instead. Acceptance requires each supported variant to remain correct after either warm-up order, with validators and expiration behaving consistently. That result says nothing about whether a model is currently healthy enough to serve a generation request.

## Primary references

[HTTP Caching](https://www.rfc-editor.org/rfc/rfc9111.html). Defines matching stored responses using Vary and freshness.

[HTTP Semantics](https://www.rfc-editor.org/rfc/rfc9110.html). Defines representation selection and the Vary response field.

[HTTP/1.1](https://www.rfc-editor.org/rfc/rfc9112.html). Explains the intermediary request path and framing needed to compare actual variants.

Related reading: [Fetching the OpenRouter model catalog before deployment](/journal/openrouter-model-catalog-api/); [Keeping model capabilities and rollout state consistent](/journal/provider-capability-rollout-consistency/).
