A URL can return different representations depending on a request header. If a cache stores only one response for that URL without accounting for the relevant difference, the next visitor may receive the wrong variant. The HTTP Vary response header communicates which request-header fields influenced the representation.
MDN’s Vary reference explains this role. Its HTTP caching guide illustrates how a cache key can include a header such as Accept-Language alongside the URL. Vary describes variation; it is not a complete policy for whether a response should be stored.
A small language example
Imagine an endpoint that genuinely chooses an English or French representation from the request’s Accept-Language value. A response might include Vary: Accept-Language. The cache must account for that field when deciding whether a stored response can satisfy another request. If the endpoint always returns the same representation, adding language variation without a reason only complicates caching.
Test with two deliberate request variants in a controlled environment. Record the request headers, returned language, Vary value and relevant cache-control headers. Repeat through the actual cache layer, not only directly against the application server. A correct origin response does not by itself prove that every intermediary is configured correctly.
Keep the Vary value consistent for the same resource where the protocol requires it, including applicable revalidation responses. Avoid casually varying on a highly diverse header such as a complete user-agent string; many variants can reduce cache reuse.
Personalised or sensitive responses need an explicit, appropriate caching policy. Do not treat adding a cookie-related Vary value as a universal privacy fix. Review the application’s authentication and cache-control behaviour together.
A useful implementation note states the reason for each listed field: “This request header changes this representation.” That makes later debugging easier than a long inherited Vary list whose entries nobody can explain.

