Skip to content

Instantly share code, notes, and snippets.

@michaelaguiar
Created September 16, 2015 19:12
Show Gist options
  • Save michaelaguiar/db8fcb95325aab4ddae8 to your computer and use it in GitHub Desktop.
Save michaelaguiar/db8fcb95325aab4ddae8 to your computer and use it in GitHub Desktop.
NGINX Browser Caching
##
# Caching
##
# Expire rules for static content
location ~* \.(?:manifest|appcache|html?|xml|json)$ {
expires -1;
# access_log logs/static.log; # I don't usually include a static log
}
# Feed
location ~* \.(?:rss|atom)$ {
expires 1h;
add_header Cache-Control "public";
}
# Media: images, icons, video, audio, HTC
location ~* \.(?:gif|png|jpg|ico|cur|gz|svg|svgz|mp4|ogg|ogv|webm|htc)$ {
expires 1M;
access_log off;
add_header Cache-Control "public";
}
# CSS and Javascript
location ~* \.(?:css|js|otf|woff)$ {
expires 1y;
access_log off;
add_header Cache-Control "public";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment