Created
March 27, 2020 17:58
-
-
Save thatryan/82c2017aede958a61172bf3f597a3b72 to your computer and use it in GitHub Desktop.
webp nginx
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
location ~* ^(/.+)\.(jpg|jpeg|jpe|png|gif)$ { | |
add_header Vary Accept; | |
if ($http_accept ~* "webp"){ | |
set $imwebp A; | |
} | |
if (-f $request_filename.webp) { | |
set $imwebp "${imwebp}B"; | |
} | |
if ($imwebp = AB) { | |
rewrite ^(.*) $1.webp; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment