Created
July 9, 2013 15:04
-
-
Save nileshgr/5958106 to your computer and use it in GitHub Desktop.
Fallback for WebP serving using nginx So you want webp files to be named as .jpeg.webp in your htdocs. You link to images in your HTML as .jpeg. Nginx will detect if browser supports webp and automatically serve webp or jpeg (File extensions do NOT decide the type).
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
if ($http_accept ~* "webp") { | |
set $webp "true"; | |
} | |
if (-e $request_filename.webp) { | |
set $webp "${webp}-local"; | |
} | |
if ($webp = "true-local") { | |
rewrite (.*) $1.webp last; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment