How to use WP Rocket with Bedrock WordPress Boilerplate

Heads Up! This tutorial is very specific and dedicated to experienced developers. Don't bother reading if you don't know how to use Bedrock.

Bedrock is an open source project by Roots and a modern WordPress stack: it's a very useful tool to configure and manage your WordPress and it includes several development tools.

To learn how to use WP Rocket on Bedrock you can follow the steps described in our blog post: How to Set Up WP Rocket on Trellis and Bedrock

⛔️ Deprecated: The following content covers a deprecated version of Bedrock.
If you still use this version, you might want to consider updating to a recent version of Bedrock.

In this doc we'll explain you how to run WP Rocket with a Bedrock-Capistrano setup.
There is another way to deploy Bedrock, Trellis, which is not covered in this tutorial.

1

Create a static advanced-cache.php and commit it to your website's Git repo.

Note: The following code is just an example. You should add your own path to this code. The exact paths are dependent on the environment within which your website is running.

<?php
defined( 'ABSPATH' ) or die( 'Cheatin\' uh?' ) ;

define( 'WP_ROCKET_ADVANCED_CACHE' , true ) ;

$root_path = WP_ENV == 'development' ? '/Users/yourlocalfolder/yoursite.local' : '/usr/share/nginx/www/current' ;
$rocket_cache_path = $root_path . '/web/app/cache/wp-rocket/' ;
$rocket_config_path = $root_path . '/web/app/wp-rocket-config/' ;

if ( file_exists( $root_path . '/web/app/plugins/wp-rocket/inc/front/process.php' ) )
{
	include( $root_path . '/web/app/plugins/wp-rocket/inc/front/process.php' ) ;
}
else
{
	define( 'WP_ROCKET_ADVANCED_CACHE_PROBLEM' , true ) ;
}
	
2

Commit the empty /cache and /wp-rocket-config folders to the Git repo (adding their contents to your .gitignore file). These directories should be set as linked directories in your Capistrano deploy script: in this way you can maintain them across releases.

Thanks to our customer Robert Sargent for providing us with this tutorial! 🎩

Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.