Thoughts on W3 Total Cache with Roots?

I was wondering what people used as a work around for the W3TC plugin? I want to use the CDN minification feature in this plugin, but it mucks up all the config files. What is a good plugin that makes it easy to minify and mirror on an AWS Cloudfront?

@cmosguy I think the easiest one would be WP Rocket.

Thanks @darjanpanic, but that is expensive, not sure how much it is worth with thatā€¦ anything free you have experience with?

Donā€™t think there are any free ones that would do the same (maybe check WP Super Cache), i would stick with W3 total cache then and just disable the features you donā€™t need. As W3 total cache is a popular plugin you can google for guides/tutorials on how to do it properly without errors and how others who took time do it. Itā€™s a great plugin if you know what each thing does and what impact it has on other things.

I suggest not using the js/css option to create one js/css file from all the plugins you use, since it will probably be a problem unless you take time and experiment. There is no 1 click option for harder things like this that i know of.

But in the end it can always be different from yours as you wonā€™t have the same plugins. Trial and error until it works :smile:

Also Sage does itā€™s own minify and it works great.

Yes. Why not use Sageā€™s minification? This generally should be part of your gulp production build tasks.

Just to add something to the CDN/caching conversation - I use WP Offload S3 for serving postā€™s/pageā€™s media assets. Iā€™ve tried to use their Assets plugin however their seems to be a bug with the folder structure of Bedrock where WP Offload canā€™t find and associate theme files. For this task I use W3TC lined into the same S3 account. Iā€™ve been told by Delicious Brains theyā€™re actively working to find a solution to this Bedrock/Sage theme issue.

Using this current setup my $5 Digital Ocean has withstood pretty high traffic ranging in the lower hundreds of thousands a day.

I found a better way to automate this;
If youā€™re already using Trellis or Bedrock, you can set a environment variable in your .env, for example:

W3T_CACHE_SECRET="somerandomstring"

Then in your gulpfile, you can read this variable with dotenv:

var dotenv       = require('dotenv').config({path: '../../../../.env'});

and use it in your gulp task:

// ### Empty Cache
gulp.task('emptycache', function(cb) {
  gulp.src('')
  .pipe(emptycache({uri: 'http://yourdomain.com/?w3tcEmptyCache=' + process.env.W3T_CACHE_SECRET}));
});

Then in your extras.php you do the same, but for PHP:

/* This allows us to automatically empty the cache during deployments */
$env = getenv('WP_ENV');
if (!$env || $env === 'production') {
  $secret = getenv('W3T_CACHE_SECRET');
}

if ( (!$env || $env === 'production') && !empty($_GET['w3tcEmptyCache']) && $_GET['w3tcEmptyCache'] == $secret && function_exists('w3tc_pgcache_flush') ) {
  // Empty the W3 Total Cache
  w3tc_pgcache_flush();
  die('W3 Total Cache Cleared');
}

Maybe this helps someone.

2 Likes

Are there (still) any Cache plugins recommended by Roots/Bedrock team?
The sites on Trellis are quite fast already without any cache plugins in use
(nginx microcaching and opcache).
Doesnā€™t the Blade cache (in Sage beta) function like a caching plugin?

I am new to using wp-super-cache, but I just found a comprehensive tutorial by Joe Lambert on how to make it play well with Bedrock and Capistrano here:

http://www.joelambert.co.uk/article/bedrock-with-wp-super-cache/

Itā€™s from 2015 but I hope it still applies.

Anyone got any more recent advice or info on cache plugins that work well with Bedrock?

If you also use Trellis for deployments, I wouldnā€™t bother using any cache plugins anymore. The fastcgi caching takes care of this.

Thanks for the tip, @Twansparant. Iā€™m using vanilla Bedrock with Apache on Docker for local development and deploying via Capistrano to cheap Cloud hosting (Apache). So I donā€™t have access to Nginx fastcgi caching at the moment.
Looks like a great solution if I ever move up to an Nginx config on something like Digital Ocean/Linode.