-
-
Save geekgonecrazy/9139621 to your computer and use it in GitHub Desktop.
This file contains 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
... | |
image/webp webp; | |
... |
This file contains 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 ~ (.+)\.(png|jpe?g)$ { | |
if ( $http_accept ~* webp ) { | |
set $webp "A"; | |
} | |
if ( $request_filename ~ (.+)\.(png|jpe?g)$ ) { | |
set $file_without_ext $1; | |
} | |
if ( -f $file_without_ext.webp ) { | |
set $webp "${webp}E"; | |
} | |
if ( $webp = AE ) { | |
add_header Vary Accept; | |
rewrite (.+)\.(png|jpe?g)$ $1.webp break; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment