Skip to content

Instantly share code, notes, and snippets.

@mosson
Created July 3, 2014 07:36
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mosson/e0c25513cf65963807ee to your computer and use it in GitHub Desktop.
Save mosson/e0c25513cf65963807ee to your computer and use it in GitHub Desktop.
webp compatible on nginx
location = /logo {
if ($http_accept ~* "webp") {
add_header Vary Accept;
rewrite (.*) $1.webp last;
}
if ($http_user_agent ~* "(Chrome|Opera|Android|Android.*Chrome)") {
add_header Vary User-Agent;
rewrite (.*) $1.webp last;
}
rewrite (.*) $1.png last;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment