Urgent.News

What's breaking now, across thousands of outlets.

Tech

We just shipped support for the ugliest part of HTTP: Vary

The "Vary" header in HTTP responses has been considered one of the more problematic aspects of the protocol due to its complexity and interoperability issues. This header informs intermediary caches about which request fields might impact the response, such as language selection, image formats, or regional content. However, simply listing these headers does not necessarily lead to optimal cache efficiency.

For example, if a server serves the same content in multiple languages, but a cache only stores each distinct header value separately, it could result in a large number of cache entries that are not truly unique. This situation can lead to suboptimal cache performance, with responses being served even though they are identical or only slightly different.

To address this challenge, Cloudflare has introduced support for Vary in its Cache Rules, allowing customers to decide how to handle variations in header values. The origin specifies which request headers may affect the response, and the customer then determines the level of variation that matters for caching. For instance, an origin might serve content in different languages and include "Vary: Accept-Language" in the response.

Cloudflare can then be configured to either ignore certain headers (like those with predictable or controlled values) or use specific strategies for others. This approach helps balance the need to serve appropriate responses with the goal of maintaining cache efficiency by avoiding the creation of an excessive number of unique cache entries.

Written by urgent.news from Lobsters's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

This story

This is one outlet's version. Read the fullest account.

Read the original at blog.cloudflare.com →

More in Tech

More from Wednesday 23 September →