Laravel Community Tools by
Tighten
Nova Packages
Laravel Tricks
Forge Recipes
Forge Recipes
Staff Picks
All Recipes
Login
Staff Picks
All Recipes
Login
Back to Recipes
Nginx expire rules for static content
10 years ago
Jaspur
un-tested
Clone
bash
Copy
rm -rf /etc/nginx/expires.conf cat >/etc/nginx/expires.conf <<EOF # Expire rules for static content #gzip gzip on; gzip_disable "msie6"; gzip_comp_level 6; gzip_min_length 1100; gzip_buffers 16 8k; gzip_proxied any; gzip_types text/plain application/xml text/css text/js text/xml application/x-javascript text/javascript application/javascript application/json application/xml+rss; # cache.appcache, your document html and data location ~* \.(?:manifest|appcache|html?|xml|json)$ { expires -1; # access_log logs/static.log; # I don't usually include a static log } # Feed location ~* \.(?:rss|atom)$ { expires 1h; add_header Cache-Control "public"; } # Media: images, icons, video, audio, HTC location ~* \.(?:jpg|woff|ttf|css|jpeg|gif|png|ico|cur|gz|svg|svgz|mp4|ogg|ogv|webm|htc)$ { expires 1M; access_log off; add_header Cache-Control "public"; } # CSS and Javascript location ~* \.(?:css|js)$ { expires 1y; access_log off; add_header Cache-Control "public"; } # add in server-block of website: # include /etc/nginx/expires.conf; EOF service nginx reload
Comments
No comments yet.
Log in
to leave a comment.