W3 Total Cache with Nginx not working?


#1

My Wordpress is with: Nginx + PHP-FPM + APC + W3 Total Cache + PageSpeed

I followed the article: http://rtcamp.com/wordpress-nginx/tutorials/single-site/w3-total-cache/

I know that the cache is working because it has a W3 Total Cache comment in the end of all HTML page.

But I have 2 questions:

1) Every time I do a request in some page, its being processed by PHP-FPM. Shouldn't W3 Total Cache supposed to prevent the request from been processed by PHP-FPM?

2) I got a cached page (with the W3 comment), stopped PHP-FPM, and I'm getting "Bad Request". Do you have any idea?

Thanks!


#2

@marcio

It is clear that during your test, caching wasn't working properly.

Did you test it from command-line (using curl) or incognito/private-mode in browser?

If you are logged in during your test, or submitted a test comment, cache will be skipped for you.


#3

I installed Varnish in front of my server, but again, it was being processed by PHP-FPM.

The problem was the lacking of slash at the end of the URL.

In Wordpress, a page is a directory, so it respond as www.mysite.com/page1/.

The point is when you hit www.mysite.com/page1 (without the slash), Nginx have to redirect to www.mysite.com/page1/ (with slash), and by doing this, it uses PHP-FPM.

After putting the slash at the end of all links in my site, the redirect was not done, and all of my page was not processed by PHP-FPM.

Thanks for the answer!


#4

@Rahul-Bansal

By the way, I know that in your opinion you don't like Nginx with Varnish.

But after using a little bit, I found same advantages of using Varnish:

1) Statistics about caching (cache hits, cache missed, memory cache size usage etc). That's useful to debug, and find when some page is cache or not.

2) In Varnish you can disable cookie for all of Wordpress, expect for Admin (to improve cache)

Does Nginx with W3 or Fast CGI Cache have something similar? I'm thinking between keep Varnish or use W3/FastCGI.

My server is Amazon Micro (613MB RAM)


#5

#1. Stats is really small thing. Rather than caching stats, you should worry about PHP-FPM stats - http://rtcamp.com/wordpress-nginx/tutorials/php/fpm-status-page/

By the way, Nginx has some stats which can be enabled here - http://rtcamp.com/wordpress-nginx/tutorials/nginx/status-page/

#2. Not sure what do you mean by cookies but if its about cookies & cache-control, then check this sample - http://rtcamp.com/wordpress-nginx/tutorials/wordpress/woocommerce/

About nginx & caching, just have a look at - http://rtcamp.com/wordpress-nginx/tutorials

There is a table there where I have already posted Nginx config’s for many type of caching techniques.

Nginx can surely do things that Varnish cannot even imagine.

Varnish was designed for caching only. For Nginx caching is just a small feature. :wink:


#6