Created
October 29, 2015 16:58
-
-
Save alenabdula/7001fa6e8f4ee3b7dbe2 to your computer and use it in GitHub Desktop.
Nginx: Serve WebP image instead of JPEG or PNG files, if browser supports it.
This file contains hidden or 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
# Check to see if .webp image is supported in the browser | |
# Serve .webp image, if avaiable, instead of .jpeg / .png | |
location / { | |
if ( $http_accept ~ "image/webp" ) { | |
rewrite (.+)\.(jpe?g|png)$ /$1.webp; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment