DevKits

Caching · Response header

Vary

Which request headers cause different cached variants of the response.

What is Vary?

Vary tells caches that responses differ depending on the listed request headers — most commonly Accept-Encoding, Accept-Language, or Origin. Without a correct Vary, a CDN might serve a gzip-encoded response to a client that cannot decode it.

Typical usage

Set on any response that varies with request headers. Almost always include Accept-Encoding when compression is enabled.

Examples

Vary: Accept-Encoding, Accept-Language

Common gotchas

Adding too many headers to Vary destroys cache hit rate — each unique combination is a separate cache entry.

Specification

RFC 9110 §12.5.5

Related headers