Skip to content

Instantly share code, notes, and snippets.

@mhemrg
Last active May 18, 2020 11:45
Show Gist options
  • Save mhemrg/95bd5cd3ecc8294f724aa04c2a59d5c2 to your computer and use it in GitHub Desktop.
Save mhemrg/95bd5cd3ecc8294f724aa04c2a59d5c2 to your computer and use it in GitHub Desktop.
Gzip settings for nginx
gzip on;
gzip_disable "msie6";
gzip_vary on;
gzip_proxied any;
gzip_comp_level 6;
gzip_types text/plain text/css application/json application/javascript application/x-javascript text/xml application/xml application/xml+rss text/javascript image/svg+xml;
location / {
index index.html index.htm;
try_files $uri $uri/ /index.html =404;
}
# cache.appcache, your document html and data
location ~* \.(?:manifest|appcache|html?|xml|json)$ {
expires -1;
}
# Media: images, icons, video, audio, HTC
location ~* \.(?:jpg|jpeg|gif|png|ico|cur|gz|svg|svgz|mp4|ogg|ogv|webm|htc)$ {
expires 1M;
access_log off;
add_header Cache-Control "public";
}
# CSS, Javascript and Fonts
location ~* \.(?:css|js|otf|ttf|eot|woff|woff2)$ {
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