Skip to content

Instantly share code, notes, and snippets.

@KevinBatdorf
Last active June 8, 2019 17:39
Show Gist options
  • Save KevinBatdorf/3f530483ef5485e0211a2cdcf77e2bd8 to your computer and use it in GitHub Desktop.
Save KevinBatdorf/3f530483ef5485e0211a2cdcf77e2bd8 to your computer and use it in GitHub Desktop.
nginx webp express + expires to add to an existing nginx config
# There is a lot of stuff before here
location ~* \.(css|js|ico|gif|webp|svg|eot|otf|woff|woff2|ttf|ogg)$ {
expires 365d;
}
location ~* ^/?content/.*\.(png|jpe?g)$ {
add_header Vary Accept;
expires 365d;
if ($http_accept !~* "webp") {
break;
}
try_files
$uri.webp
/content/plugins/webp-express/wod/webp-on-demand.php?xsource=x$request_filename&wp-content=content
;
}
location ~* ^/?content/.*\.(png|jpe?g)\.webp$ {
try_files
$uri
/content/plugins/webp-express/wod/webp-realizer.php?wp-content=content
;
}
location ~* \.(pdf)$ {
expires 30d;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment