Thoughts on W3 Total Cache with Roots?


#21

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?


#22

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


#23

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


#24

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.


#25

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.


#26

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.


#27

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?


#28

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?


#29

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


#30

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.