Skip to content

Instantly share code, notes, and snippets.

@sapegin
Created July 8, 2013 18:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sapegin/5951367 to your computer and use it in GitHub Desktop.
Save sapegin/5951367 to your computer and use it in GitHub Desktop.
# Force the latest IE version
# Use ChromeFrame if it's installed for a better experience for the poor IE folk
add_header "X-UA-Compatible" "IE=Edge,chrome=1";
# Static files
location ~* \.(?:png|jpg|jpeg|gif|ico|svg|svgz|swf|woff|eot|otf|ttf|ttc|mp3|mp4|ogg|ogv|webm)$ {
expires 1M;
access_log off;
log_not_found off;
add_header Cache-Control "public";
}
# JS and CSS
# Probably 1Y should be set only inside /build
location ~* \.(?:js|css)$ {
expires 1y;
access_log off;
log_not_found off;
add_header Cache-Control "public";
}
# Favicon
location = /favicon.ico {
expires 1M;
access_log off;
log_not_found off;
add_header Cache-Control "public";
}
# Robots
location = /robots.txt {
expires 7d;
access_log off;
log_not_found off;
}
# Prevent clients from accessing hidden files (starting with a dot)
location ~* (?:^|/)\. {
deny all;
}
# Prevent clients from accessing to backup/config/source files
location ~* (?:\.(?:bak|config|sql|ini|log|sh|inc|swp|dist|py|coffee|pyc)|~)$ {
deny all;
}
location ~* package.json$ {
deny all;
}
# Do not cache .appcache, HTML and data
location ~* \.(?:manifest|appcache|html?|xml|json)$ {
expires -1;
}
# Do not log 404 for some files
location = /apple-touch-icon.png { log_not_found off; }
location = /apple-touch-icon-precomposed.png { log_not_found off; }
# Cache open file handles, "not found" errors, metadata about files and their permissions, etc.
# https://github.com/h5bp/server-configs/blob/master/nginx/conf/cache-file-descriptors.conf
open_file_cache max=1000 inactive=20s;
open_file_cache_valid 30s;
open_file_cache_min_uses 2;
open_file_cache_errors on;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment