Nginx – webp

This is how you can easily make Nginx serving webp images if disponible & if browser support it.

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;
}
}
}
view raw nginx_webp.conf hosted with ❤ by GitHub

Répondre à Kimesdardom Annuler la réponse

Votre adresse de messagerie ne sera pas publiée.

Commentaire sur “Nginx – webp”

Search
Generic filters
Exact matches only
Filter by Custom Post Type