Skip to content

Instantly share code, notes, and snippets.

@dimobelov
Forked from uhop/nginx-webp-sample.conf
Last active May 20, 2019 08:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dimobelov/13b9d4d4d5442965cb9e40a95bc42a50 to your computer and use it in GitHub Desktop.
Save dimobelov/13b9d4d4d5442965cb9e40a95bc42a50 to your computer and use it in GitHub Desktop.
Serving WEBP with nginx conditionally.
location ~* ^/images/.+\.(png|jpg)$ {
root /home/www-data;
add_header Vary Accept;
try_files "${uri}.webp" $uri =404;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment