Cloudflare

Vary for Images: Serve the Correct Images to the Correct Browsers

Sep 13, 2021Alex Krivit
Vary for Images: Serve the Correct Images to the Correct Browsers
SummaryAI, from the source post

Introduced support for the HTTP Vary header specifically for images, enabling the serving of different image formats (e.g., WebP, AVIF) based on the browser's Accept header. This feature ensures that intermediate caches, like Cloudflare's, serve the correct image variant to each user-agent, preventing the delivery of incompatible or unoptimized content. The implementation involves parsing the Accept header and creating distinct cache entries for each image variant. Configuration for Vary for Images is available via the Cloudflare API for Pro, Business, and Enterprise customers, supporting specific file extensions and requiring origin servers to send the `Vary: Accept` response header. Purging varied images will purge all content variants for that URL.

More from the Cache Management trail