You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
check the content-type of response header is `webp`
### Some explain for way 2
It works really nice, but what’s under the hood? For every request nginx creates two variables $webp_ext and $file_ext
$webp_ext equals .webp if current browser sends image/webp in the Accept header. Or it equals empty string otherwise.
$file_ext equals file extension (e.g. .png) of current URI if current URI has it. Or it equals empty string otherwise.
In the location for images, the $path without extension is captured from incoming URI. And after that nginx tries to find a WebP version by concatenating $path and $webp_ext variables. If the file doesn’t exist nginx will try the next $path and $file_ext.
You will see a legacy file extension in the URI whether it’s WebP or not, but browsers are okay with that because nginx sends correct Content-Type for WebP files.