Skip to content

Instantly share code, notes, and snippets.

@stef-k
Last active September 4, 2016 07:16
Show Gist options
  • Save stef-k/4f9eed093881720ec4752bb7a8d10072 to your computer and use it in GitHub Desktop.
Save stef-k/4f9eed093881720ec4752bb7a8d10072 to your computer and use it in GitHub Desktop.
# put this in nginx.conf http block
proxy_cache_path /var/cache levels=1:2 keys_zone=nginx_cache:10m max_size=10g inactive=60m
use_temp_path=off;
# on vhost config put
proxy_cache nginx_cache;
# This block will catch static file requests, such as images, css, js
# The ?: prefix is a 'non-capturing' mark, meaning we do not require
# the pattern to be captured into $1 which should help improve performance
location ~* \.(?:ico|css|js|gif|jpe?g|png|woff|ttf|otf|svg|woff2|eot)$ {
# Some basic cache-control for static files to be sent to the browser
expires 30d; // or use max
add_header Pragma public;
add_header Cache-Control "public, must-revalidate, proxy-revalidate";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment