The purpose of the Vary header is to inform shared caches, such as CDNs and proxies, that the response varies, and the cache should therefore not only be keyed by URL, but also by the value(s) in the header.
As the webp format is gaining momentum, there is an increase in solutions where (origin) servers returns webp for browsers that supports it and jpeg / png for browsers that doesn’t. To signal the varied response, these solutions add a Vary:Accept header. The solution has been around for a while, and KeyCDN has also written about it in your blog: https://www.keycdn.com/blog/convert-to-webp-the-successor-of-jpeg.
There are multiple ways you can implement this.
- You can always forward Accept headers to origin servers, or only when configured to
- You can always use the Accept header as key, when the origin server returns a Vary:Accept header, or only when configured to
- You can narrow it down so instead of using the whole Accept header as key, you can transform it into a boolean, which is TRUE when the Accept header contains “image/webp” in the string, and FALSE otherwise. This will limit the number of variation to just two - and thus limiting the disk space needed AND increase the chance for a HIT. Currently there are not too many variations of Accept headers around (https://developer.mozilla.org/en-US/docs/Web/HTTP/Content_negotiation/List_of_default_Accept_values#Values_for_an_image), but this might change