Cloudflare Ships Support for Vary Header
Cloudflare has released support for the Vary header, a feature described as 'the ugliest part of HTTP' but essential for correct caching.
Cloudflare has released support for the Vary header, a feature described as 'the ugliest part of HTTP' but essential for correct caching. According to the company, the Vary header is a standard HTTP response header that tells intermediary caches, such as Cloudflare, which request fields may affect the response sent by the origin. This header is crucial for serving different languages, image formats, compression schemes, or regional content from the same URL.
The Vary header is necessary to prevent caches from serving the wrong response to requesting clients. However, it introduces a challenge: when two requests contain different header values, it is not always clear whether they need different responses. Cloudflare's new support for Vary allows users to decide how the cache handles each header, enabling normalization of known negotiation headers, passing exact values through when small differences matter, or bypassing cache when the variation is too unpredictable.
Vary support is now available in Cache Rules on every plan, giving users control over how Cloudflare caches handle varying request fields.
Source: cloudflare
