Skip to content

Instantly share code, notes, and snippets.

@pekkis
Created February 20, 2013 10:51
Show Gist options
  • Save pekkis/4994732 to your computer and use it in GitHub Desktop.
Save pekkis/4994732 to your computer and use it in GitHub Desktop.
Cache settings for nginx
# odp
location ~* ^.+\.(odt|odp)$ {
access_log off;
gzip off;
expires 30d;
}
# non-zipped images
location ~* ^.+\.(jpg|jpeg|gif|png|ico)$ {
access_log off;
gzip off;
expires 30d;
}
# gzipped images
location ~* ^.+\.(svg)$ {
access_log off;
gzip on;
expires 30d;
}
# Documents
location ~* ^.+\.(css|js|html|txt)$ {
access_log off;
expires 30d;
gzip on;
charset utf-8;
}
# Web fonts, gzipped
location ~* ^.+\.(eot|ttf|otf|woff)$ {
access_log off;
gzip on;
expires 30d;
add_header Access-Control-Allow-Origin *;
}
# archives
location ~* ^.+\.(pdf|gz|bz2|exe|rar|zip|7z)$ {
access_log off;
gzip off;
}
# videos
location ~* ^.+\.(mp4|avi)$ {
access_log off;
gzip off;
}
# bad regexes
location ~* (\.svn|\.git) {
access_log off;
deny all;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment