[Plugin: W3 Total Cache] W3 Total Cache with Squid?
-
Hi,
I’m a great fan of W3 Total Cache and have been installing it on most of the WordPress sites I manage. While tweaking it might sometimes be tricky, I’ve been mostly successful, both on shared and dedicated hosting.
But on one case I have stumbled upon an issue. This is a FreeBSD server, having a Squid proxy in front of several jails (FreeBSD pseudo-virtual servers), each running its own Apache. The individual jails are not directly accessible from the outside (they’re on a private IP range), only Squid is (because it runs on the FreeBSD host with a public IP address).
When installing WordPress, I almost immediately install and configure W3TC, before even selecting a theme, and normally I’m logged in to the admin panel, so W3TC is not really caching anything. So it was only after a few weeks that I noticed that all those sites were unusually slow when viewing them not logged in. First I assumed it was just the server misbehaving or being under heavy load. But then this was happening consistently. Worse: sometimes the delay until the first page was loaded was measured in minutes, and not seconds. Of course the browser cache would make this a little less worrying for subsequent pages, but it was worrying. There are several CMS installed on that server, and every site served by WordPress was taking tens or hundreds of times to fully load on an empty browser cache. Something was clearly wrong with W3TC, so I checked and re-checked all options, did all the upgrades, and so forth. If anything, things seemed to become worse.
When testing it from external online website testing sites (like http://redbot.org, but I’ve tested several others), I was getting very inconsistent header results. The strangest thing was that everything took, say, a few minutes to start loading, but then the rest appeared relatively quickly. It looked like a slow connection or DNS problem, but that didn’t make any sense: tests made to other, non-WordPress-hosted sites on the same server (even on the same jail, and thus served by the same Apache behind Squid) had absolutely no issue and loaded fast like always. Nobody ever complained about all the other sites anyway, it was just WordPress misbehaving.
Googling for some hints on what was wrong, I came to the conclusion that somehow W3TC requires special handling when working together with Squid (and might ultimately make little difference, since Squid has such an extraordinary performance). W3TC is clearly labeled as supporting Squid, but no configuration options are suggested. I found a single link to this: http://ww.wp.xz.cn/support/topic/plugin-w3-total-cache-recommened-w3tc-settings-when-used-with-squid — note that it is claimed that “there are no specific settings for squid”.
Well, this is clearly not correct. Turning W3TC off and letting WordPress run without any caching plugin whatsoever resulted in a speed increase of hundreds of times for all sites hosted with WordPress in that server (so I excluded some problems with specific themes or plugin combinations). This was consistently reproduced, using all the tests that I had used before. Instead of the long waiting time of hundreds of seconds for the connection to start showing any signs of having anything to return, now it takes the usual miliseconds. From being the slowest CMS on that server, it’s by far the fastest — the irony is that all others use their specialised caching mechanisms, but WordPress is currently being the one without any cache whatsoever…
Please don’t take this as a complaint or merely some whining… that’s not intended. As said, I have a wonderful experience with W3TC on dozens and dozens of configurations (with and without Cloudflare; with and without APC; with more or less Apache support, and so forth). The only case I found W3TC actually seriously interfering with the performance was this combination where a public Squid has to talk to an Apache on a private network. I seriously suspect that there are some crazy header redirections that are causing tons of timeouts, until finally something comes through the connection. It might be Squid getting seriously confused by W3TC’s headers (or just some of them) and waiting for timeouts before serving the pages, or forcing WP+W3TC to serve uncached pages before sending them back to the user. Squid might require some tweaking in order to work well with W3TC (and W3TC might actually be doing everything right!).
So, I’d like to know if anyone has a similar setup, which is not that infrequent. For security reasons, if you have several sites, it’s always best to have them run on private networks (either in the same server, using some kind of virtualization technique, or on physically different servers), and just have a farm of Squid servers with public addresses in front of them all (and possibly Cloudflare, or a similar CDN/proxy system, in front of that as well!). So I’m sure this kind of setup is not that infrequent; I’ve seen it in many occasions in my clients. Under those circumstances, I’m pretty sure that someone has managed to get W3TC to “play nice” with Squid.
Any pointers would be most welcome. For now, turning W3TC off keeps the client happy (their WP sites now outperform pretty much anything on the universe…), and so the issue is not so urgent for me any more, but on the other hand, there are a lot of CPU cycles being wasted by making unnecessary database calls, when W3TC could so easily improve things (also, the Apache server runs Xcache, although I never managed to get W3TC to work well with Xcache — even though I have no problem using W3TC with APC. Different problem, different thread!)
Thanks in advance!
The topic ‘[Plugin: W3 Total Cache] W3 Total Cache with Squid?’ is closed to new replies.