Skip to content
WJunction - Webmaster Forum

Advise on Nginx Config

Are you interested in such kind of post?

  • No, thanks

    Votes: 0 0.0%

  • Total voters
    3
  • Poll closed .
Status
Not open for further replies.
==How to enable gzip compression in nginx for static files and speed up your site ==
tonginx configuration file /etc/nginx/nginx.conf add in "http"directive these lines:

gzipon;
gzip_disable"msie6";
gzip_varyon;
gzip_proxiedany;
gzip_comp_level6;
gzip_buffers16 8k;
gzip_typestext/plain text/css application/json application/x-javascripttext/xml application/xml application/xml+rss application/javascript text/javascript;

Savefile and restart the nginx:

/etc/init.d/nginxrestart

Afterthat all the css and javasripts files will be compressed on the server side and your sites will work faster

Sincerely, Olga Secom
 

5 comments

Also i always cache images too. add this to server {}

location ~* .(jpg|jpeg|png|gif|ico|css|js)$ {
expires 365d;
}

and the: service nginx reload
 
actually that's not real caching.
you just advise the clients to set a timeout for the reload of the files from your server.
so it's more a client-side caching.
if you do this, don't forgett to add a time-tag (or s.th. else) to your code, in order to push changes to your clients, without having them to clear their caches.

i prefere to not use expires 365d but instead just use
Code:
expires max;


for real caching look at s.th. like reverse-proxy, php-apc, memcached etc :)
 
Last edited:
Status
Not open for further replies.

About the author

O
Member · Joined
yoga
15
Messages
3
Reactions
3
Points

Tags

Advertise on WJunction

Reach 1000's of webmasters, hosts & affiliates. Banner & sponsored-thread slots available.

Contact us
Back
Top Bottom