ManageWP: how to clear WP Rocket cache

You can clear WP Rocket cache from your  ManageWP control panel.

To do it, you can use the following snippet. 
It has to be added to ManageWP’s Code Snippet feature.

This snippet will also check if you have Sitemap Preload enabled, and it will trigger the preload if that's the case.

<?php 
 
// Load WordPress environment
require( 'wp-load.php' );
 
// Load WP Rocket environment
require( 'wp-content/plugins/wp-rocket/wp-rocket.php' );
require( 'wp-content/plugins/wp-rocket/inc/functions/i18n.php' );
require( 'wp-content/plugins/wp-rocket/inc/functions/formatting.php' );
require( 'wp-content/plugins/wp-rocket/inc/functions/options.php' );
require( 'wp-content/plugins/wp-rocket/inc/API/preload.php' );
 
// Clear the cache
if ( function_exists( 'rocket_clean_domain' ) ) {
	rocket_clean_domain();
	echo 'Cache cleared';
}
 
// Preload the cache
// First, check if Sitemap preload is enabled
if ( function_exists( 'get_rocket_option' ) ) { 
    $sitemap_preload 	= get_rocket_option( 'sitemap_preload');
}
 
if( $sitemap_preload == 1 ) { 
	// run sitemap preload
	if ( function_exists( 'run_rocket_sitemap_preload' ) ) { 
	   run_rocket_sitemap_preload(); 
	   echo ' - Sitemap Preload started';
	}
}
Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.