• Resolved athleticcity

    (@athleticcity)


    Hello WP‑Optimize Support Team,

    I am using WP‑Optimize in a WordPress multisite directory installation and would like to prevent the cache from being automatically cleared during plugin updates or WordPress core updates.

    At the same time, all regular cache‑clearing events should continue to work normally — for example when pages, posts, or products are deleted or updated. Only the automatic purge triggered by system or plugin updates should be disabled.

    Is there a built‑in option, filter, or hook that allows me to disable cache clearing specifically during updates?

    If not, is there a recommended way to implement this behavior via a custom function placed inside the /mu-plugins/ directory so that the cache remains intact during updates, while all other purge mechanisms continue to operate as expected?

    Thank you very much for your assistance.

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Support jbgupdraft

    (@jbgupdraft)

    Hi,

    Thanks for contacting us! I do have a code snippet that can be added to an mu-plugin that will suppress the cache purging when plugins are activated/deactivated or updated however I’m still trying to locate where we purge the cache when WordPress Core gets updated and I haven’t validated the code on a multisite environment. I will do some testing and try to locate the hook for WordPress Core and then can provide a code snippet to be added as an mu-plugin.

    I’ll send it over as soon as it’s ready.

    Thanks!

    Plugin Support jbgupdraft

    (@jbgupdraft)

    Hi,

    Just a quick question, are you using any of the minification features with WP-Optimize?

    Thanks!

    Thread Starter athleticcity

    (@athleticcity)

    Hi, thanks for your response.
    No, I don’t use any of the minification features under /wp-admin/network/admin.php?page=wpo_minify. I only use the table optimization and cache features.

    Plugin Support jbgupdraft

    (@jbgupdraft)

    Hi,

    Thanks so much for the info! I’ve run some tests in my multisite environment with this code added to a PHP file added to the mu-plugins directory. I tested updating plugins and themes, activating and deactivating plugins as well as WordPress core updates and the cache remained the same and was not purged. Hopefully this works the same for you on your site!

    <?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]);

    }

    if($actionValue == "upgrader_overwrote_package"){

    unset($actions[$actionKey]);

    }

    }

    }

    return $actions;

    }

    add_filter('wpo_purge_page_cache_on_activate_deactivate_plugin', '__return_false');

    Let me know how it goes!

    Thread Starter athleticcity

    (@athleticcity)

    Hi,

    I just updated a plugin and the cache was not cleared. It looks like it’s working.

    Thank you very much.

    Plugin Support jbgupdraft

    (@jbgupdraft)

    Hi,

    I just want to check if we’re okay to mark this post as resolved?

    Thanks!

Viewing 6 replies - 1 through 6 (of 6 total)

You must be logged in to reply to this topic.