webp-convert
webp-convert copied to clipboard
WebP on demand with Varnish
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:
- ReqHeader user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:89.0) Gecko/20100101 Firefox/89.0
- ReqHeader accept: image/webp,/
- ReqHeader accept-language: en-US,en;q=0.5
- VCL_call RECV
- ReqHeader WebP: true
- ReqURL /wp-content/plugins/testplugin/webp/webp-on-demand.php?source=/var/www/html/testsitewp.com/wp-content/uploads/2021/07/Test-Image.jpg
- VCL_return pass
- VCL_call HASH
- ReqHeader newUrl: /wp-content/plugins/testplugin/webp/webp-on-demand.php?source=/var/www/html/testsitewp.com/wp-content/uploads/2021/07/Test-Image.jpg
- VCL_return lookup
- VCL_call PASS
- VCL_return fetch
- Link bereq 1081946 pass
- Timestamp Fetch: 1625558896.108284 0.023647 0.023647
- RespProtocol HTTP/1.1
- RespStatus 404
- RespReason Not Found
- RespHeader Server: nginx
- RespHeader Date: Tue, 06 Jul 2021 08:08:16 GMT
- RespHeader Content-Type: text/html; charset=UTF-8
- RespHeader Vary: Accept-Encoding
- RespHeader X-WebP-Convert-Log: Image type could not be detected
- RespHeader X-WebP-Convert-Log: Performing fail action: original
- RespHeader X-WebP-Convert-Log: Performing fail action: original
- RespHeader Cache-Control: no-store, no-cache, must-revalidate, max-age=0, post-check=0, pre-check=0
- RespHeader Pragma: no-cache
- RespHeader X-WebP-Convert-Log: Performing fail action: 404
- RespHeader Content-Encoding: gzip