This part is checking whether the client’s Accept header contains image/webp.
This part checks whether a file ending in .jpeg has an existing .jpeg.webp present equivalent on disk.
This part then proceeds to rewrite to that file, which will ensure the webp variant is served.
In Caddy 2, you’d use a named matcher to sum up all those conditions - including checking for the .webp sidecar - and rewrite to whatever the file matcher finds. The following snippet should handle all three:
Thank you so much for that, but is it possible to rewrite this url “/wp-content/uploads/2015/04/image1.jpg” to “/wp-content/uploads-webpc/2015/04/image1.jpg.webp” like in that Nginx configuration in my #3 anwser
Regexes are little computers with somewhat complex state machines, so yes if we’re talking number of CPU instructions, they are always slower than specialized algorithms – but 99.9% of users won’t notice any impact, because computers are fast and networks are not.