You can try adding the following filter;
add_filter(‘wpo_purge_post_on_update’, ‘__return_false’);
You can also set your cache lifespan to 0, so that cache is preloaded only when the cache is emptied
Thank you so much for the help. I will try the filter.
Hi Team, I tried the filter, but still Plugin updates cleared the cache.
Do you have any other solution?
Hi,
Can you try this? This needs to be created as an mu-plugin since this will not be triggered in your theme functions.php upon a plugin update. If you don’t have an mu-plugins folder inside your wp-content folder you can create it manually and then add this as a new PHP file:
<?php
/**
* Plugin Name: WPO Update Listener
* Description: Fires a custom action when plugins or themes are updated.
*/
add_filter('wpo_purge_cache_hooks', 'disable_cache_purge_wpo', 10, 1);
function disable_cache_purge_wpo($actions){
foreach($actions as $actionKey => $actionValue){
if(!is_array($actionValue)){
if($actionValue == "wpo_active_plugin_or_theme_updated"){
unset($actions[$actionKey]);
}
}
}
return $actions;
}
I’ve tested this on one of my sites hopefully it works for you too!
@jbgupdraft , thanks for the snippet.
I tried it as a mu plugin. Still no luck. I deactivated a plugin and it cleared the cache automatically. It would be great you bring that option to the plugin by default in the future updates.
Thank you!
Hi,
Plugins being deactivated would be a different action that runs. I’ll continue looking through the code to see if I can find an additional action or filter to hook into and send you another snippet for the MU-Plugin.
Hi,
Thanks for your patience! I was able to locate another filter that can be hooked into on plugin activation / deactivation that will stop the page cache from clearing automatically. If you can replace the existing MU-Plugin with the snippet below, let me know if it works for you!
<?php
/**
* Plugin Name: WPO Update Listener
* Description: Fires a custom action when plugins or themes are updated.
*/
add_filter('wpo_purge_cache_hooks', 'disable_cache_purge_wpo', 10, 1);
function disable_cache_purge_wpo($actions){
foreach($actions as $actionKey => $actionValue){
if(!is_array($actionValue)){
if($actionValue == "wpo_active_plugin_or_theme_updated"){
unset($actions[$actionKey]);
}
}
}
return $actions;
}
add_filter('wpo_purge_page_cache_on_activate_deactivate_plugin', '__return_false');
Hi @jbgupdraft,
The new snippet you provided worked; however, it cleared the minified files, which caused errors on the frontend since the cached files were still referring to them.
Can you help to prevent that as well?
Thank you!
Hi,
Glad to hear we’re making some progress. Just to double check, was the minify cached cleared for you when deactivating a plugin or running a plugin update?
Thank you. I updated a plugin and the minified files got cleared.
Hi,
I was able to find a couple of actions to remove for the minification cache. I’ve tested this on one of my sites and updating a plugin has not been purging the minified files. Hopefully it works out for you too!
<?php
/**
* Plugin Name: WPO Update Listener
* Description: Fires a custom action when plugins or themes are updated.
*/
add_filter('wpo_purge_cache_hooks', 'disable_cache_purge_wpo', 10, 1);
function disable_cache_purge_wpo($actions){
foreach($actions as $actionKey => $actionValue){
if(!is_array($actionValue)){
if($actionValue == "wpo_active_plugin_or_theme_updated"){
unset($actions[$actionKey]);
}
}
}
return $actions;
}
add_filter('wpo_purge_page_cache_on_activate_deactivate_plugin', '__return_false');
add_action('plugins_loaded', 'prevent_minify_cache_clear');
function prevent_minify_cache_clear(){
remove_action('upgrader_process_complete', array('WP_Optimize_Minify_Cache_Functions', 'cache_increment'));
remove_action('wpo_active_plugin_or_theme_updated', array('WP_Optimize_Minify_Cache_Functions', 'reset'));
}