Welcome Guest. Please Login or Register  


You are here: Index > Webuzo > General Support > Topic : Wordpress Cache plugin with Nginx



Threaded Mode | Print  

 Wordpress Cache plugin with Nginx, Enable compression, Leverage browser caching problems (6 Replies, Read 37523 times)
9tablets
Group: Member
Post Group: Newbie
Posts: 1
Status:
Hello,

First of all, i would like to say Webuzo is just AWESOME. I'm planing to use it on my new VPS server.

I just installed a clean install and activated the free 15 days trial, then i installed LEMP stack and wordpress.
Every thing seems to work fine, but my problem that i couldn't get any cache plugin to work with Nginx, i tried w3 total cache, wp super cache with no success.

Enable compression and Leverage browser caching always red and page speed around 50-60 /100.

I tried to configure "/usr/local/apps/nginx/etc/conf.d/common" and "/usr/local/apps/nginx/etc/conf.d/webuzoVH.conf" but it doesn't work at all.

would you please guide me to solve this problem?

Thank you.


IP: --   

Wordpress Cache plugin with Nginx
valley
Group: Webuzo Team
Post Group: Super Member
Posts: 1644
Status:
Sir all of the NGINX configurations related to your site should go in the file :
/usr/local/apps/nginx/etc/conf.d/common

And restart the NGINX service for the changes to take effect.

Probably you must be applying invalid configurations thus causing the trouble.

-----------------------
Webuzo : Single User Control Panel
Join Webuzo :
Facebook
Twitter

IP: --   

Wordpress Cache plugin with Nginx
awran5
Group: Member
Post Group: Newbie
Posts: 3
Status:
No way, i tried to configure the "/usr/local/apps/nginx/etc/conf.d/common " file with no luck.

i tried to add try_files $uri $uri/ /index.php?q=$uri;
and i always do restart to NGINX. even i reinstalled webuzo and wordpress again used cleared the cache files, different browser .. no way.

would you please just tell the right code and the right place to add into this file?

Thank you
IP: --   

Wordpress Cache plugin with Nginx
valley
Group: Webuzo Team
Post Group: Super Member
Posts: 1644
Status:
You can follow this guide to learn the basics of NGINX configuration and proceed with your changes accordingly.
https://library.linode.com/web-servers/nginx/configuration/basic

Quote
location = / {

This line serves requests at the document root. Did you install your script at the root of a domain or a sub-directory ?
If NO, then you are adding the configuration at the wrong line.

-----------------------
Webuzo : Single User Control Panel
Join Webuzo :
Facebook
Twitter

IP: --   

Wordpress Cache plugin with Nginx
awran5
Group: Member
Post Group: Newbie
Posts: 3
Status:
it works FINALLY  :xd:   now my page speed is 95/100 !!

I've added this code to "/usr/local/apps/nginx/etc/conf.d/webuzoVH.conf"

PHP Code

 server {
        
rewrite ^(.*) http://site.com$1 permanent;
}

# Define default caching of 1 week
expires 31536000s;
add_header Pragma public;
add_header Cache-Control "max-age=31536000, public, must-revalidate, proxy-revalidate"



and this code to "/usr/local/apps/nginx/etc/conf.d/common"

PHP Code

 # Use gzip compression
# gzip_static on; # Uncomment if you compiled Nginx using --with-http_gzip_static_module
gzip on;
gzip_disable "msie6";
gzip_vary on;
gzip_proxied any;
gzip_comp_level 5;
gzip_buffers 16 8k;
gzip_http_version 1.0;
gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript image/png image/gif image/jpeg;
# Rewrite minified CSS and JS files
location ~* .(css|js) {
if (!-
f $request_filename) {
rewrite ^/wp-content/w3tc/min/(.+.(css|js))$ /wp-content/w3tc/min/index.php?file=$1 last;
# Use the following line instead for versions of W3TC pre-0.9.2.2
# rewrite ^/wp-content/w3tc/min/([a-f0-9]+)/(.+).(include(-(footer|body))?(-nb)?).[0-9]+.(css|js)$ /wp-content/w3tc/min/index.php?tt=$1&gg=$2&g=$3&t=$7 last;
}
}
# Set a variable to work around the lack of nested conditionals
set $cache_uri $request_uri;
# POST requests and urls with a query string should always go to PHP
if ($request_method POST) {
set $cache_uri 'no cache';
}
if (
$query_string != "") {
set $cache_uri 'no cache';
}
# Don't cache uris containing the following segments
if ($request_uri ~* "(/wp-admin/|/xmlrpc.php|/wp-(app|cron|login|register|mail).php|wp-.*.php|index.php|wp-comments-popup.php|wp-links-opml.php|wp-locations.php)") {
set $cache_uri "no cache";
}
# Don't use the cache for logged in users or recent commenters
if ($http_cookie ~* "comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_logged_in") {
set $cache_uri 'no cache';
}
# Use cached or actual file if they exists, otherwise pass request to WordPress
location / {
try_files /wp-content/w3tc/pgcache/$cache_uri/_index.html $uri $uri/ /index.php?q=$uri&$args;
}
 
# Cache static files for as long as possible
location ~* .(xml|ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|css|rss|atom|js|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf)$ {
try_files $uri =404;
expires max;
access_log off;
}
# Deny access to hidden files
location ~* /.ht {
deny all;
access_log off;
log_not_found off;




i followed this tutorial:
http://elivz.com/blog/single/wordpress_with_w3tc_on_nginx/
IP: --   

Wordpress Cache plugin with Nginx
valley
Group: Webuzo Team
Post Group: Super Member
Posts: 1644
Status:
Sir please make sure you take a backup of the files.

The file webuzoVH.conf is rebuilt every time you add/delete a domain and other cases.

We shall have these changes reviewed and implemented by default in the upcoming version of Webuzo.

-----------------------
Webuzo : Single User Control Panel
Join Webuzo :
Facebook
Twitter

IP: --   

Wordpress Cache plugin with Nginx
awran5
Group: Member
Post Group: Newbie
Posts: 3
Status:
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  ;-D

.
IP: --   

« Previous    Next »

Threaded Mode | Print  



Jump To :


Users viewing this topic
1 guests, 0 users.


All times are GMT. The time now is April 28, 2024, 7:59 am.

  Powered By AEF 1.0.8 © 2007-2008 Electron Inc.Queries: 11  |  Page Created In:0.025