rosell-dk / webp-convert

Convert jpeg/png to webp with PHP (if at all possible)
MIT License
578 stars 102 forks source link

WebP on demand with Varnish #292

Open krazyipman opened 3 years ago

krazyipman commented 3 years ago

Hi,

We are trying to integrate varnish and webp. We already disabled caching of jpg,png and jpeg within varnish.

Our problem is that it seems webp on demand is unable to convert and provide the original file. We have this configuration in our nginx location ~ ^/?wp-content/..(png|jpe?g)$ { add_header Vary Accept; expires 365d;

if ($http_accept !~* "webp"){ break; } try_files /wp-content/testdir/webp-images/doc-root/$uri.webp $uri.webp /wp-content/plugins/testplugin/webp/webp-on-demand.php?source=$request_filename ; }

Here is varnishlog output: