Skip to main content
All CollectionsGetting StartedMaking Website Faster
How to Configure WP Rocket Plugin for WordPress
How to Configure WP Rocket Plugin for WordPress

Learn how to Install and confiture WP Rocket Plugin for WordPress website on Cloudways platform.

Usama Zafar avatar
Written by Usama Zafar
Updated over 3 months ago

Table of Contents

This guide will explain how you can use the WP Rocket plugin with your WordPress/ WooCommerce website on the Cloudways Platform.

Tip

Cloudways has launched its own cache plugin called Breeze – WordPress Cache Plugin.

How to Configure WP Rocket Plugin for WordPress

Step 1: Download WP Rocket Plugin

Go to the WP Rocket site and choose the plan as per your requirements. Place the order after filling a small form and then download the zip file to your local computer.

Step 2: Log in to WordPress Admin

Log in to the WordPress admin area of your site with your credentials.

Step 3: Remove W3 Total Cache

You need to deactivate and delete W3 Total Cache (Cloudways default caching plugin) and any other installed optimization plugins from your WordPress site to avoid any conflicts.

Step 4: Install WP Rocket

Under the Add Plugins section, click on the Upload Plugin option. Then click Choose File to provide the path of your downloaded WP Rocket zip file and click the Install Now button.

Once installed, then activate the plugin from the Installed Plugins section. License activation happens when you activate the plugin, so no need to enter an API key.

Step 5: Configuring WP Rocket

Page caching is activated by default when you activate WP Rocket. Likewise, optimal rules for browser caching, GZIP, and other performance enhancements are also added by default to your .htaccess file.

Varnish Cache Purge

If the Varnish service is enabled on your server at Cloudways (it is by default), then go to the Varnish tab in WP Rocket and check the box to Enable the Varnish caching auto-purge.

This replaces the need to use the Varnish HTTP Purge plugin.

Cloudways provides OPCache too, and you will automatically see a Purge OPCache link in the WP Rocket admin toolbar in case you need to purge it.

Purge Varnish When Using a Proxy

When you use a proxy, e.g. Cloudflare, clearing varnish cache may not work effectively.

To fix this, you will need to use the following code snippet as explained below:

  1. Create a folder named mu-modules in your wp-content folder. Do not create another folder if mu-modules already exist.

  2. Using a basic text editor create a new file and put the following code in it.

Tip

Remember to replace example.com with your domain name.

<?php
defined( 'ABSPATH' ) or die( 'Cheatin&#8217; uh?' );
/**
* Plugin Name: Fix Varnish Auto Purge with Proxy and WP Rocket
* Author: WP Rocket Support Team
* Author URI: http://wp-rocket.me/
* License: GNU General Public License v3 or later
* License URI: http://www.gnu.org/licenses/gpl-3.0.html
*/

add_filter( 'rocket_varnish_purge_request_host', '__rocket_varnish_custom_hostname' );
function __rocket_varnish_custom_hostname() {
return 'example.com';
}


add_filter( 'rocket_varnish_ip', '__rocket_varnish_custom_ip' );
function __rocket_varnish_custom_ip() {
return 'localhost';
}

3. Save the file as wp-rocket-varnish-purge-proxy.php
4. Upload this file to the mu-modules folder created in step 1.
5. Finally, make sure to deactivate and re-activate WP Rocket (you may also need to manually clear the cache of your proxy).

To verify if Varnish was properly cleared, you can check the Age header. To do that in Chrome, first, open Developer Tools:
Chrome Menu → More Tools → Developer Tools OR Press Ctrl+Shift+I

Then click on the Network tab, and reload your website.

Look at the first request and check the value of the age header. This is the age of the Varnish cache, in seconds.


Immediately after purging, it will reset to 0.

LazyLoad and Minification

LazyLoad and minification can cause display issues, depending on the specific theme and plugins you are running. So we recommend enabling those options 1-by-1, then checking your site in a logged-out window, to see if there are any issues.

If you have issues, consult the documentation on resolving them:

You can also disable the option and clear the cache to set your site back to normal.

Minification and Varnish

In order to run WP Rocket CSS / JS minification while Cloudways Varnish is activated, you can add a URL exclusion of /(.*)/?f=(.*) . This will allow the minification process to run smoothly.

  1. Under Application Management, Click Application Settings.

  2. Go to the Varnish Settings tab and click on Add New Exclusion to add the value as shown in the screenshot.

    Classic Interface

    New Interface

Preload Bot

Depending on your site, the preload bot can consume additional server resources. If you have any issues with it, it can be easily disabled by following this simple guide.

Check the WP Rocket documentation if you have any additional problems.

That’s it! We hope this article was helpful. If you need any help, then feel free to search your query on Cloudways Support Center or contact us via chat (Need a Hand > Send us a Message). Alternatively, you can also create a support ticket.


Quick Tip

Cut down server loads with Cloudways built-in cache plugins, and enjoy speed boosts. Start Today.

Did this answer your question?