Skip to content

Instantly share code, notes, and snippets.

@hilios
Created October 13, 2011 12:57
  • Star 7 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save hilios/1284170 to your computer and use it in GitHub Desktop.
Nginx YSlow performance boost w/ Gzip + Far future expires Header
server {
# output compression saves bandwidth
gzip on;
gzip_http_version 1.1;
gzip_vary on;
gzip_comp_level 6;
gzip_proxied any;
gzip_types text/plain text/html text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
# make sure gzip does not lose large gzipped js or css files
# see http://blog.leetsoft.com/2007/7/25/nginx-gzip-ssl
gzip_buffers 16 8k;
# Disable gzip for certain browsers.
gzip_disable “MSIE [1-6].(?!.*SV1)”;
location ~* ^.+\.(jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|pdf|txt|tar|wav|bmp|rtf|js|flv|swf|html|htm)$ {
expires 30d;
access_log off;
}
# location ~* \.(ico|css|js|gif|jp?g|png) {
# if ($args ~ [0-9]+) {
# expires max;
# break;
# }
# }
}
@chaffeqa
Copy link

set Expire header on assets: see http://developer.yahoo.com/performance/rules.html#expires

location ~ ^/(images|javascripts|stylesheets)/ {
expires 1h;
}

@vjlamba
Copy link

vjlamba commented Dec 27, 2013

it shows 500 error when i used this code in my .Htaccess file..plz help

@zedd45
Copy link

zedd45 commented Jan 21, 2014

@vjamba .htaccess is typically for use with Apache. This gist is about Nginx. Are you attempting to convert from Apache to Nginx? If so, this link may help you: http://stackoverflow.com/questions/8711678/change-apache-htaccess-file-to-be-used-with-nginx

@web-differently
Copy link

pls how i can add the script gistfile1.txt
in nginx

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment