Vary: User-Agent ignored?


#1

Hello,
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


#2

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 @cscharff can explain better.


#3

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”.


#4

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