Created
January 25, 2019 17:46
-
-
Save Eddy-Barraud/6adf36bc9cba649b470f8500aaaf68d5 to your computer and use it in GitHub Desktop.
Serves webp images instead of jpg or png if supported by browser
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
http { | |
## | |
# WebP conf | |
## | |
map $http_accept $webp_suffix { | |
default ""; | |
"~*webp" ".webp"; | |
} | |
## | |
# Minimal server | |
## | |
server { | |
[...] | |
location ~* ^/images/.+\.(png|jpe?g)$ { | |
root /home/www-data; | |
add_header Vary Accept; | |
try_files $uri$webp_suffix $uri =404; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment