Report this

What is the reason for this report?

How do setup gzip & leverage browser caching properly

Posted on March 5, 2014
eli

By eli

Running Ubuntu 12.0.4 Nginx

Is there anything else recommended for speeding sites up?



This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

you can make sure Nginx.conf has the following: <br> <br> gzip on; <br> gzip_vary on; <br> gzip_disable “MSIE [1-6].”; <br> gzip_proxied any; <br> gzip_http_version 1.1; <br> gzip_min_length 0; <br> gzip_comp_level 4; <br> gzip_buffers 16 8k; <br> <br>and you can use x-cache to cache php mainly… <br> <br>you can use some nginx modules to compress or combine css and js files. <br> <br>you can compress images as well through many ways to speed up the site load time

Thank you! Do you know the steps required to leverage caching?

you just need to add this to your nginx vhost block: <br> <br>location ~* .(js|css|png|jpg|jpeg|gif|ico)(?ver=[0-9.]+)?$ { <br> expires 1y; <br>} <br> <br>or add this for more caching to other things you have on your site: <br> <br>location ~* ^.+.(jpg|jpeg|gif|png|svg|js|css|mp3|ogg|mpeg|avi|zip|gz|bz2?| <br>rar|swf)$ { <br> expires 7d; <br> }

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.