Can't get Webp to work

I have Polish enabled to Lossy and Webp selected. From other threads, the conclusion was CF will not convert to Webp if it was not worth doing so, i.e. the conversion does not shrink the image more than the original.

On Google Insights, the biggest problem it shows on my mobile website is “Serve images in next-gen formats” because none of the images were served in Webp.

I will give an example. I have an image that is 208kb and a screen grab from my Insights test


The test suggests the image could be reduced significantly and I tested with an online converter and the image was reduced to just 33kb webp.

Polish is working when I looked at the response header

Cf-Bgj: imgq:85,h2pri
Cf-Polished: origSize=238468, status=vary_header_present

What can I do to get webp to work?

Polish does not go well with “vary” header values that are anything but “accept-encoding.”

vary_header_present: The origin web server has sent a Vary header with a value other than accept-encoding . If the origin web server is attempting to support WebP, disable WebP at the origin web server and let Polish perform the WebP conversion.

Do you mean this header?

Vary: User-Agent, Accept-Encoding

It is accept-encoding in the response header.

But it’s adding the “user-agent” value, which would imply serving responses according to each user agent’s capabilities. That is normally added by plugins when WebP is served out of the origin, but with Polish you should serve image in their non-WebP formats and let Polish serve the WebP format for browsers that accept it, and the original images (JPG, PNG, GIF) to browsers that don’t.

1 Like

Thank you.

Now my problem is how to “disable WebP at the origin web server and let Polish perform the WebP conversion.” :sweat_smile:

I’m not using Wordpress btw. It is a PHP website.

You’d probably get better answers for this on and similar sites, as this is of course off-topic for this community, and you have greater chances of a fast solution if you provide more details re: your origin server config. My wild guess would be your server probably has mod_pagespeed enabled, in which case it wouldn’t be difficult to google for how to disable WebP at the origin.

Been looking around for a solution and found one.

For those using Apache/Litespeed, a few lines in the .htaccess file

<ifModule mod_headers.c>
Header unset Vary
Header set Vary "Accept-Encoding"

Hope this helps anyone with the same problem. Thanks @floripare for setting me in the right direction.

1 Like

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