Polish: Lossy with PNG? Not getting WebP

Hello everyone, on mein-schoener-garten.de/shop/ I am not seeing any WebP being used. What could be the reason?

Also, many images that should have been compressed with JPEG were compressed as PNG. Will Polish compress them to lossy WebP, or am I stuck with lossless WebP at best?


The way Polish works is by only converting images is there is going to be a benefit in doing so and reduction in the size of the image - if there is no benefit, then it serve either just the lossy original file format, or if your file was already compressed from your origin, will serve the original file. The image also needs to be served from Cloudflare cache and returning a cf-cache-status: hit to be polished!

Lets look at an example from your site.

You can see it is a cf-cache-status: hit, but in the cf-polished header it is returning an status warning:

The presence of the header vary: user-agent is preventing Polish from running correctly, Cloudflare by default only supports the use of vary: accept-encoding

you would need to update your vary header from your origin, and then polish may run correctly on the image ( but may not because you can see the origSize=62270, but the content-length is 13088, so there is already some compression happening here.

$ curl -svo /dev/null 'https://shop-api.mein-schoener-garten.de/medias/200Wx200H-198e10dc-cd6f-45bc-be60-300488023a9b.jpg?context=bWFzdGVyfGltYWdlc3w2MjI3MHxpbWFnZS9qcGVnfGFHVXhMMmc1TXk4NE9ERTFNVGt3TXpjMk5EYzRMekl3TUZkNE1qQXdTRjh4T1RobE1UQmtZeTFqWkRabUxUUTFZbU10WW1VMk1DMHpNREEwT0Rnd01qTmhPV0l1YW5CbnwzOWVhMjBlY2NiZmUwNjM3YzU2NmM5YmUwNzdiNTM3ZmUxNDZmYmI2YmZlMjc1ZTZkN2QwNzg4ZGQ4NmEwYzQ4' -H 'accept: image/webp' 2>&1 | egrep -i '< cf-|content-l|content-t|vary'
< content-type: image/jpeg
< content-length: 13088
< cf-bgj: imgq:85,h2pri
< cf-polished: degrade=85, origSize=62270, status=vary_header_present
< vary: User-Agent
< x-content-type-options: nosniff
< cf-cache-status: HIT
< cf-ray: 851c5f89b89036d9-YYZ
< cf-team: 1e259a0a05000036d91fdad400000001

Hope this helps!


Thank you Damian, yes, that helps. I’ll try to get the header changed.

Do you know if Cloudflare will use lossy WebP for PNGs (that show photos) if we have set Polish to lossy?

Polish can convert png to webp (if you use lossy or lossless) but only if there is a benefit in doing so and there will be additional compression achieved with webp - if there is no benefit, then png will continue to be served.

Sometimes the ‘status’ value returned in the cf-polished response header will give you an indication of whats happening (eg. webp_is_bigger).

Which form of WebP though? Lossy or lossless? There would be significant benefit (50 kb instead of 2 MB) if converting to lossy WebP, little if using lossless. But I thought somewhere I read that Polish thinks PNG should only be compressed lossless, as it is a lossless format and surely the uploader meant it to stay that way. Hopefully that is not the case.

Hi Daniel,

Sorry for the delay - I think you are referring to this guide - Polish compression · Cloudflare Image Optimization docs

Lossless - “This option attempts to remove EXIF data from GIF, PNG, and JPEG files. However, it only applies lossless compression to GIF and PNG files, as JPEG files are inherently lossy.”

Lossy - “Although this option tries to remove EXIF data from GIF, PNG, and JPEG files, it only applies compression to JPEG files. Lossy has the same effect as Lossless when applied to PNG.”

WebP - “If you choose the Lossless Polish setting, then WebP will be used very rarely. This is due to the fact that, in this mode, WebP is only adequate for PNG images, and cannot improve compression for JPEG images.”

To answer your question, it would use lossless compression for Polish if converting a png to webp.

This topic was automatically closed after 15 days. New replies are no longer allowed.