Vary: User-Agent ignored?

our Server serves different Image File Formats based on Users User-Agent. (jpg for Firefox, WebP for Chrome)
We send “Vary: User-Agent,Accept-Encoding” Header on all those Files.

But it seems that Cloudflare is ignoring this Header and is only caching one Variant (jpg or webp - whatever is served first)

So when first Access is done with Chrome - the WEBP Image Format is cached - and all Images are broken for Firefox Users which can’t decode WebP …

How to configure Cloudflare that it’s respecting the Vary Header correct?

Thank you, bye from sunny Austria
Andreas Schnederle-Wagner

I don’t think Cloudflare will cache different versions of the same image. You would have to bypass caching for those images. Or use the Pro plan with Polish which…oddly enough…can deliver different versions of the same image.

Maybe @Ryan or @cs-cf can explain better.

That is correct - we only vary the cache based on the URI currently, except for Enterprise customers who can use custom cache keys to do this.

Note that our Polish image optimisation will automatically optimise & optionally return WebP for clients that support it, so your origin doesn’t have to.

If that isn’t suitable, right now you would need to disable caching for those images by using a page rule with a cache level of “Bypass Cache”.


Unfortunately, I already feared that - thanks! :weary:

The worst part if that if you already did any kind of optimisation to your images, Polish won’t work (even the webp version won’t be delivered).

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.