Skip to content

Instantly share code, notes, and snippets.

@reatlat
Created May 24, 2020 12:30
Show Gist options
  • Select an option

  • Save reatlat/ff1577845e6840430e2ba59dceec6385 to your computer and use it in GitHub Desktop.

Select an option

Save reatlat/ff1577845e6840430e2ba59dceec6385 to your computer and use it in GitHub Desktop.
http {
[...]
# webp support
# see: https://docs.ewww.io/article/16-ewww-io-and-webp-images
map $http_accept $webp_suffix {
default "";
"~*webp" ".webp";
}
server {
[...]
location ~* ^.+\.(png|jpe?g)$ {
### Please change the domainname before uncommenting the following
# valid_referers none blocked www.example.com example.com;
# if ($invalid_referer) { return 403; }
# add_header Vary Accept;
# see https://docs.ewww.io/article/16-ewww-io-and-webp-images
try_files $uri$webp_suffix $uri =404;
expires max;
log_not_found off;
access_log off;
}
[...]
}
[...]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment