Thank you,
But i found better way to solve all "Enable compression" and "Leverage browser caching" problems with Nginx. you don't need all previous codes, even it works without any cache plugins like W3 total cache or WP super cache.
i posted this little tutorial at webhostingtalk but i like to share it with softculous fans.
Tested on CentOS 6.4 with Webuzo installed and Ubuntu 12.04 only LEMP installed.
Step 1: add this code just after the server name line:
- If you use centos / webuzo: PHP Code vi /usr/local/apps/nginx/etc/conf.d/webuzoVH.conf
Note: as (valley) mentioned webuzoVH.conf file is rebuilt every time you add/delete a domain and other cases.
- If you use ubuntu:PHP Code nano /etc/nginx/sites-enabled/yoursite
The code is:
PHP Code server_name yoursite.com;
# Define default caching of 1 week
expires 31536000s;
add_header Pragma public;
add_header Cache-Control "max-age=31536000, public, must-revalidate, proxy-revalidate";
gzip_types text/plain text/css application/json application/javascript application/x-javascript text/javascript text/xml a$
Step 2: make sure gzip is on
Edit or add these lines in:
- If you use centos / webuzo: in the Enduser panel > Nginx
- If you use ubuntu: PHP Code nano /etc/nginx/nginx.conf
The code is:
PHP Code gzip on;
gzip_http_version 1.1;
gzip_vary on;
gzip_comp_level 5;
gzip_proxied any;
gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
gzip_buffers 16 8k;
gzip_disable “MSIE [1-6].(?!.*SV1)”;
And finally restart Nginx:
PHP Code sudo service nginx restart
That's all, now delete your browser cache and refresh the page and your page speed result should be over 90/100
.
|