Yeah I just noticed that after I had posted it. I’m not sure what’s up with the lack of updates. Basically it just changes the core WP caches, transients, etc. instead of being stored in the database to be stored in memcached.
I don’t think I’ve heard about a lot of issue with it, but I don’t have extensive experience with it. I have Varnish set up on my personal site.
With having a site that’s fully SSL, I have to use NGINX for the SSL termination in conjunction with Varnish right? Also, I’m using a DO VPS that has 1gb of RAM, do you think that’s enough to run Varnish, NGINX and OPCache? I’m using Bedrock Ansible’s default playbook at the moment.
I was just about to post a topic on Cache, I’ll roll my questions / comments here.
Re: Varnish, is that something Bedrock-Ansible may include? Seems more powerful than Memcached but maybe it’s a bit much.
On the current Bedrock-Ansible setup Memcached gets installed but is that the only step? I’ve used Memcached on AWS and they supply a node (url) to connect use. If it’s just running on the server is that enough?
The thing to keep in mind is that Varnish and Memcached are different.
Memcached is more of your standard cache, you can save chunks of HTML or code to it, and it stores it in memory for much faster retrieval than if you were to cache something in say the database or a file. Something like Batcache changes WP’s own cache, including transients, to be stored in Memcached rather than the database.
Varnish is also a type of cache, but works completely differently. It sits in front of Apache or Nginx as a reverse proxy. It then takes entire pages of your site, saves the HTML output, and stores that in memory. So when someone clicks on your site, they are first being served by Varnish. If Varnish has the page cached, it returns it from memory and that’s where the huge time savings are. If it does not have the page cached, it passes it on to Apache or Nginx to handle the actual request.
Varnish is great if your site can use it, but it’s rather opinionated and obviously has issues with more dynamic sites, so I wouldn’t suggest that it be installed by default on something like Bedrock.
You’d need to install the batcache + WP memcached plugin yourself and set some constants in WP config. But other than that it’s all ready to go. The plugins default to the standard local memcached settings so you don’t need to configure that unless you were going to use some external memcached instance.
I haven’t had much luck with any of the more comprehensive cacheing solutions. Most require some kind of setup that can’t be handled programmatically.
I can release my Varnish VCL - it’s fairly complex and has comprehensive conditional statements that control cache headers. I highly recommend Varnish over any of the WP cacheing solutions, as it can be controlled through configuration, which tends to make scaling and deployment much easier.
I don’t know if I’d say Varnish is “opinionated,” it just doesn’t have exceptions built in for WordPress. In fact, given the fact that it’s a blank slate out of box, I’d say it’s the reverse of “opinionated.” It does exactly what you tell it to do. Nothing more, nothing less. It’s extremely flexible and you can script it to do just about anything. We have it controlling cookies and headers as well.
I haven’t tried WP Rocket, but I have tried W3TC and Super Cache - and as I understand it, WP Rocket isn’t that far off conceptually.
Another nice thing about Varnish is that you can use it as a WAF (Web Application Firewall). There are VCLs that mimic OWASP mod_sec rules.
Also, be careful about the 1gb limit. To get the full benefit of Varnish, you’ll need to mallloc it, and you should give it plenty of overhead.
Here’s an older version that doesn’t have as many site specific rules in it. I need to go through and refactor this so it’s a clean VCL that I augment with site specific VCLs. Please don’t use this out of the box - it does need some care, and the rules need to refactored so you don’t have to pipe around them.
Hopefully this helps a bit. There’s a dearth of good source material for VCLs out there.
Again - this is not done and requires a good amount of work, but should give you a good headstart
@brandon Also, instead of nginx handling the termination, you could use HAProxy, which would open up the possibility of horizontally scaling your installation later. Since WP uses cookie based sessions by default, horizontal scaling is fairly straightforward. HAProxy is also faster and more capable as a load balancer than nginx.
So does anyone have solutions for when something like Varnish is overkill? I’m a little hesitant to move to Memcached given a lack of clear instructions on setting up Batcache and Memcached Backend… and both plugins on WP.org being more than 2 years out of date. There is also the issue of creating advanced-cache.php (and possibly other config files) in app/ and how to handle those for deployments.
I work at a small university, for the most part caching is not necessary but I still like to have it setup for cases when some event or news item drives up a bunch of traffic randomly (think emergency situations - active shooter, fire, etc). I feel like Varnish and Memcached are both a little overkill and reach diminishing returns when it comes to setup and configuration compared to WP Super Cache and a properly configured Nginx. But WP Super Cache does not seem to fit into Bedrock since it populates the app/ directory with advanced-cache.php which may or may not change with new versions. I avoid W3TC as it is too complex and bloated. Super Cache provides a nice simple page cache, I just wish I could find a way to set it up with Bedrock so as to not destroy the principals behind the project.
Basically you just cache every page for a very short amount of time so you don’t need to worry about cache invalidation. Note that this only applies to users who aren’t logged in which is usually for traffic spikes.