Disable All Automatic Cache Clearing

Note: This tutorial refers to WordPress action hooks. If you understand code and are not familiar with the concept yet, you can learn more about it here.

There are numerous actions that can trigger a full or partial deletion of the cache.

The most common are:

  • Clear Cache Lifespan
    The whole cache will be deleted automatically according to the time period you specify in the Basic Options.
  • New Content
    When you publish new content or update/edit existing content, the cache for that and related content (e.g. taxonomy archives) will be cleared and preloaded. You can learn more about that here:
    How Is The Cache Preloaded

Here is the full list of other actions that trigger full cache deletion:

  • changing themes
  • creating/updating/deleting users (if you run a busy e-commerce site with a lot of orders, those orders could be creating new users and therefore causing frequent cache deletion)
  • updating navigational menus
  • updating theme options
  • creating/updating/deleting sidebar widgets
  • creating/updating/deleting categories, tags, or permalink structures
  • creating/updating/deleting terms
  • creating/updating/deleting links (the post type “Link” that was removed from WorPress core in version 3.5, but may still be used via a plugin)
  • when any options are saved in the Customizer
  • when the Avada theme clears its own cache

Actions that will trigger partial cache deletion:

  • creating/updating/deleting posts or pages
  • creating/updating/deleting comments on a post

Avoid Automatic Cache Clearing

If you want to prevent these actions, you can easily do so by using the following in a MU plugin.

Custom MU Plugin

Follow the general instructions in this article:
How to Make a Custom (MU) Plugin

Create a folder named mu-plugins in your wp-content folder.
In case a mu-plugins folder already exists, don’t create a new one, just use the existing one.
Using a basic text editor create a new file and put the following code in it:
defined( 'ABSPATH' ) or die( 'Cheatin&#8217; uh?' );
 * Plugin Name: WP Rocket | Disable Automatic Cache Purge
 * Description: Disables automatic cache purging in 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

// Disables the deletion of the entire cache.
add_action( 'wp_rocket_loaded', 'rocket_remove_all_purge_hooks' );

 * Remove all of WP Rocket’s cache purging actions.
 * @return void
function rocket_remove_all_purge_hooks() {

	// WP core action hooks rocket_clean_domain() gets hooked into.
	$clean_domain_hooks = array(
		// When user changes the theme
		// When a user is added
		// When a user is updated
		// When a user is deleted
		// When a custom menu is updated
		// When any theme modifications are updated
		'update_option_theme_mods_' . get_option( 'stylesheet' ),
		// When you change the order of widgets
		// When category permalink prefix is update
		// When tag permalink prefix is update
		// When permalink structure is update
		// When a term is created
		// When a term is updated
		// When a term is deleted
		// When a link (post type) is added
		// When a link (post type) is updated
		// When a link (post type) is deleted
		// When resulty are saved in the Customizer
		// When Avada theme purges its own cache

	// WP core action hooks rocket_clean_post() gets hooked into.
	$clean_post_hooks = array(
		// Disables the refreshing of partial cache when content is edited

	// Remove rocket_clean_domain() from core action hooks.
	foreach ( $clean_domain_hooks as $key => $handle ) {
		remove_action( $handle, 'rocket_clean_domain' );

	// Remove rocket_clean_post() from core action hooks.
	foreach ( $clean_post_hooks as $key => $handle ) {
		remove_action( $handle, 'rocket_clean_post' );

	remove_filter( 'widget_update_callback'	, 'rocket_widget_update_callback' );
Save the file as wp-rocket-no-purge.php
Upload this file to the mu-plugins folder created in step 1.
Finally, make sure to deactivate and re-activate WP Rocket.