Cloud Computing and Data Centers

Cloudflare Enables Control Over HTTP Response Variance via Cache Rules for All Plans

Cloudflare has added support for the HTTP Vary header within Cache Rules on all plans, with options to normalize header values, pass them through unchanged, or bypass caching. The update aims to prevent incorrect responses and reduce cache fragmentation caused by inconsequential differences in requests.

2026-09-22
4 min read
324 views
certi.news Editorial Team
Cloudflare Enables Control Over HTTP Response Variance via Cache Rules for All Plans

Cloudflare announced support for the HTTP response header Vary within its Cache Rules feature across all of its plans, including Free, Pro, Business, and Enterprise. The addition gives website administrators greater control over how the network handles requests that may produce multiple representations of the same resource, such as differences in language, image format, content type, or compression method.

The origin server uses Vary to identify request headers that can affect the response, but the header does not indicate whether every textual difference between the values of those headers actually leads to a different response. As a result, the caching system may treat similar values as separate variants, fragmenting content into a large number of items with low reuse.

Three Ways to Handle Variance

Cloudflare provides one of three actions for each header named by the origin in Vary:

  • normalize: Normalize values before selecting the stored variant. This is the recommended option for negotiation headers such as Accept, Accept-Language, and Accept-Encoding when many values map to a limited number of responses.
  • passthrough: Use the raw value, including capitalization, spaces, ordering, and duplicate values, when the precise difference affects the response.
  • bypass: Do not cache the response if the header named in Vary is personal or highly variable, such as Cookie or User-Agent.

Vary: * always causes caching to be bypassed, because any part of the request, including information outside the HTTP message such as the IP address, may affect the origin's selection of the response.

What Changes in Practice?

When normalization is used, requests that look different but prefer the same result can share the stored variant. Cloudflare reduces Accept, Accept-Language, and Accept-Encoding values to a standardized form, making the values lowercase and sorting them according to quality priority, with alphabetical ordering in the event of a tie. The administrator can also specify supported media types or languages, such as text/html and application/json or en, fr, and de.

However, this behavior may eliminate differences that the origin needs. Cloudflare notes that q=0 values or certain language exclusions may be lost during abbreviation, so passthrough should be used if the origin needs to see those exclusions exactly as sent by the client. Passing through raw values may also recreate the fragmentation problem; values such as compact,full and compact, full may produce different cache keys even if the origin treats them as equivalent.

Origin Responsibility and Update Limitations

The origin must return Vary consistently with every cacheable response that may differ according to request headers, including fallback responses and errors. If one response omits the appropriate header, Cloudflare may cache that response without the required isolation.

Changing Vary settings does not automatically delete existing content; old entries may remain until they expire or a purge operation is performed. Vary configuration also does not replace a custom cache key in every case: Cloudflare recommends using a custom key when a request property is a fixed part of the resource's identity, and using Vary when the origin declares, in its response, the fields that actually affect it.

Why Does This News Matter?

The update addresses a practical trade-off in CDN networks: ignoring Vary may send the wrong format or language to the client, while treating every value literally may reduce the cache hit rate and increase requests returning to the origin. According to the article, an analysis of more than 120 million responses from approximately 50,000 popular websites showed that nearly 3,000 websites use variance across four or more fields, with some using 10, 23, or 47 fields.

The benefit remains tied to the quality of the origin's definition of the representations it provides and to selecting the appropriate action for each header. The settings are available through the Cloudflare dashboard, the Rulesets API, or Terraform, with the need to test different values and monitor CF-Cache-Status after deployment.

News source
Cloudflare Blog
Open original source ↗
c
Author

certi.news Editorial Team

What you need to know

Cloudflare has added HTTP Vary header support to Cache Rules for all plans, with three options: normalize values, pass them through as-is, or bypass caching. The update aims to reduce errors caused by serving inappropriate variants and reduce cache fragmentation, but its success depends on consistent origin settings and choosing the appropriate action for each header.

  • Vary support in Cache Rules is available for Free, Pro, Business, and Enterprise plans.
  • Each header in Vary can be configured with normalize, passthrough, or bypass.
  • normalize is suitable for negotiation headers such as Accept, Accept-Language, and Accept-Encoding when many values result in a limited number of responses.
  • passthrough should be used when nuances such as q=0 or language exceptions affect the response.
  • Vary: * always bypasses caching, and bypass may also be appropriate for highly variable headers such as Cookie and User-Agent.
  • Changing Vary settings does not automatically remove previously cached content; it may need to expire or be purged.

FAQ

What options does Cloudflare provide for handling Vary?

Values can be normalized with normalize, the raw value can be passed through with passthrough, or caching can be bypassed with bypass.

Does changing Vary settings delete previously cached content?

No. Older entries may remain until they expire or a purge is performed.

When should a custom cache key be used instead of Vary?

Cloudflare recommends a custom cache key when a request property is a fixed part of the resource's identity, and Vary when the origin declares the fields that actually affect the response.

In the same category

You may also like

View all news