Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Serves webp images instead of jpg or png if supported by browser
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
You can’t perform that action at this time.