Title: Clear Cache after Automatic Updates
Last modified: December 2, 2021

---

# Clear Cache after Automatic Updates

 *  Resolved [jrunkel](https://wordpress.org/support/users/jrunkel/)
 * (@jrunkel)
 * [4 years, 6 months ago](https://wordpress.org/support/topic/clear-cache-after-automatic-updates/)
 * Recently I’ve found that the styles of some websites are broken after automatic
   updates of WordPress or some plugins. After clearing the cache (especially the
   minified css files) they rendered fine again.
 * For this reason I switched to another cache plugin on one website. Since the 
   issue reoccurred on another website I investigated more and finally found this
   thread and the resulting solution:
    [https://wordpress.org/support/topic/auto-clear-cache-after-updates-2/](https://wordpress.org/support/topic/auto-clear-cache-after-updates-2/)
   [https://www.wpfastestcache.com/features/clear-cache-after-theme-or-plugin-update/](https://www.wpfastestcache.com/features/clear-cache-after-theme-or-plugin-update/)
 * This helps with the problem. But since it requires some active research and manual
   manipulation of the wp-config.php file I would suggest that you enable this feature
   by default. Many users do have automatic updates for plugins enabled and wake
   up a day with a broken website. This is probably not what you want …
    -  This topic was modified 4 years, 6 months ago by [jrunkel](https://wordpress.org/support/users/jrunkel/).
      Reason: changed link of wpfastestcache.com (inserted wrong one in original
      post)

Viewing 15 replies - 1 through 15 (of 21 total)

1 [2](https://wordpress.org/support/topic/clear-cache-after-automatic-updates/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/clear-cache-after-automatic-updates/page/2/?output_format=md)

 *  Plugin Author [Emre Vona](https://wordpress.org/support/users/emrevona/)
 * (@emrevona)
 * [4 years, 6 months ago](https://wordpress.org/support/topic/clear-cache-after-automatic-updates/#post-15124591)
 * you are right. this feature was like a beta feature. I will make it as a default
   feature and let you know.
 *  Thread Starter [jrunkel](https://wordpress.org/support/users/jrunkel/)
 * (@jrunkel)
 * [4 years, 6 months ago](https://wordpress.org/support/topic/clear-cache-after-automatic-updates/#post-15165188)
 * Thanks for your reply. I’d love to see an update for this feature.
 * Today my site was broken again after an automatic update of the following plugins:
 * – Elementor (from version 3.4.8 to 3.5.0)
    – Essential Addons for Elementor (
   from version 4.9.6 to 4.9.7)
 * This happened though I had added these two lines to the `wp-config.php`:
 *     ```
       define("WPFC_CLEAR_CACHE_AFTER_PLUGIN_UPDATE", true);
       define("WPFC_CLEAR_CACHE_AFTER_THEME_UPDATE", true);
       ```
   
 * Is there any reliable technique as of today, that I can use to prevent this?
 *  Plugin Author [Emre Vona](https://wordpress.org/support/users/emrevona/)
 * (@emrevona)
 * [4 years, 6 months ago](https://wordpress.org/support/topic/clear-cache-after-automatic-updates/#post-15165194)
 * are you using another cache system as well or any other optimization plugin?
 *  Thread Starter [jrunkel](https://wordpress.org/support/users/jrunkel/)
 * (@jrunkel)
 * [4 years, 6 months ago](https://wordpress.org/support/topic/clear-cache-after-automatic-updates/#post-15165244)
 * No, I don’t have any other caching / optimization plugin installed. Not sure 
   how Elementor internally handles CSS, though.
 *  Plugin Author [Emre Vona](https://wordpress.org/support/users/emrevona/)
 * (@emrevona)
 * [4 years, 6 months ago](https://wordpress.org/support/topic/clear-cache-after-automatic-updates/#post-15165276)
 * is the problem solved when you clear all cache manually?
 *  Thread Starter [jrunkel](https://wordpress.org/support/users/jrunkel/)
 * (@jrunkel)
 * [4 years, 6 months ago](https://wordpress.org/support/topic/clear-cache-after-automatic-updates/#post-15165302)
 * Yes, that’s what I do to fix it.
 *  Thread Starter [jrunkel](https://wordpress.org/support/users/jrunkel/)
 * (@jrunkel)
 * [4 years, 6 months ago](https://wordpress.org/support/topic/clear-cache-after-automatic-updates/#post-15165307)
 * (I’m using the second option “Delete cache and minified CSS/JS”.)
 *  Plugin Author [Emre Vona](https://wordpress.org/support/users/emrevona/)
 * (@emrevona)
 * [4 years, 6 months ago](https://wordpress.org/support/topic/clear-cache-after-automatic-updates/#post-15165454)
 * can you update the line 136 and 140 as below please?
 * > if(true){
 * [https://plugins.trac.wordpress.org/browser/wp-fastest-cache/trunk/wpFastestCache.php#L136](https://plugins.trac.wordpress.org/browser/wp-fastest-cache/trunk/wpFastestCache.php#L136)
 * [https://plugins.trac.wordpress.org/browser/wp-fastest-cache/trunk/wpFastestCache.php#L140](https://plugins.trac.wordpress.org/browser/wp-fastest-cache/trunk/wpFastestCache.php#L140)
 *  Thread Starter [jrunkel](https://wordpress.org/support/users/jrunkel/)
 * (@jrunkel)
 * [4 years, 6 months ago](https://wordpress.org/support/topic/clear-cache-after-automatic-updates/#post-15165572)
 * I changed them to the following:
 *     ```
       if(defined("WPFC_CLEAR_CACHE_AFTER_PLUGIN_UPDATE") && WPFC_CLEAR_CACHE_AFTER_PLUGIN_UPDATE){
       	if(isset($_GET['DEBUG']) && $_GET['DEBUG']=='PLUGINS') { echo 'Clearing after plugin updates is activated!'; exit; }
       	add_action('upgrader_process_complete', array($this, 'clear_cache_after_update_plugin'), 10, 2);
       }
   
       if(defined("WPFC_CLEAR_CACHE_AFTER_THEME_UPDATE") && WPFC_CLEAR_CACHE_AFTER_THEME_UPDATE){
       	if(isset($_GET['DEBUG']) && $_GET['DEBUG']=='THEME') { echo 'Clearing after theme updates is activated!'; exit; }
       	add_action('upgrader_process_complete', array($this, 'clear_cache_after_update_theme'), 10, 2);
       }
       ```
   
 * Calling [http://www.mydomain.com/?DEBUG=PLUGINS](http://www.mydomain.com/?DEBUG=PLUGINS)
   and [http://www.mydomain.com/?DEBUG=THEME](http://www.mydomain.com/?DEBUG=THEME)
   I get the defined outputs and exits. I guess that is what you wanted to assure?
 *  Plugin Author [Emre Vona](https://wordpress.org/support/users/emrevona/)
 * (@emrevona)
 * [4 years, 6 months ago](https://wordpress.org/support/topic/clear-cache-after-automatic-updates/#post-15165650)
 * are they working properly?
 *  Thread Starter [jrunkel](https://wordpress.org/support/users/jrunkel/)
 * (@jrunkel)
 * [4 years, 6 months ago](https://wordpress.org/support/topic/clear-cache-after-automatic-updates/#post-15165672)
 * The debug flags that I added are working properly, yes.
 * (But this isn’t a solution to the original problem.)
 *  Plugin Author [Emre Vona](https://wordpress.org/support/users/emrevona/)
 * (@emrevona)
 * [4 years, 5 months ago](https://wordpress.org/support/topic/clear-cache-after-automatic-updates/#post-15167356)
 * I have no idea.
 *  Thread Starter [jrunkel](https://wordpress.org/support/users/jrunkel/)
 * (@jrunkel)
 * [4 years, 5 months ago](https://wordpress.org/support/topic/clear-cache-after-automatic-updates/#post-15190240)
 * I added some debugging output to your plugin and traced down the issue. In the
   two functions you’re checking the type of update which is fine but also you are
   checking the list of affected plugins/themes. This is where the problem lies 
   because the list of plugins/themes is not present when only a single plugin/theme
   gets an automatic update.
 * The `$options` param looks like this in these situations:
 *     ```
       Array
       (
           [plugin] => elementor/elementor.php
           [type] => plugin
           [action] => update
       )
       ```
   
 * To fix the issue please change these lines:
 *     ```
       public function clear_cache_after_update_plugin($upgrader_object, $options){
       	if($options['action'] == 'update'){
       		if($options['type'] == 'plugin' && isset($options['plugins'])){
       			$this->deleteCache(true);
       		}
       	}
       }
   
       public function clear_cache_after_update_theme($upgrader_object, $options){
       	if($options['action'] == 'update'){
       		if($options['type'] == 'theme' && isset($options['themes'])){
       			$this->deleteCache(true);
       		}
       	}
       }
       ```
   
 * to the following:
 *     ```
       public function clear_cache_after_update_plugin($upgrader_object, $options){
       	if($options['action'] == 'update'){
       		if($options['type'] == 'plugin'){
       			$this->deleteCache(true);
       		}
       	}
       }
   
       public function clear_cache_after_update_theme($upgrader_object, $options){
       	if($options['action'] == 'update'){
       		if($options['type'] == 'theme'){
       			$this->deleteCache(true);
       		}
       	}
       }
       ```
   
 *  Thread Starter [jrunkel](https://wordpress.org/support/users/jrunkel/)
 * (@jrunkel)
 * [4 years, 5 months ago](https://wordpress.org/support/topic/clear-cache-after-automatic-updates/#post-15190242)
 * Or even shorter:
 *     ```
       public function clear_cache_after_update_plugin($upgrader_object, $options){
       	if($options['action'] == 'update' && $options['type'] == 'plugin'){
       		$this->deleteCache(true);
       	}
       }
   
       public function clear_cache_after_update_theme($upgrader_object, $options){
       	if($options['action'] == 'update' && $options['type'] == 'theme'){
       		$this->deleteCache(true);
       	}
       }
       ```
   
 *  Plugin Author [Emre Vona](https://wordpress.org/support/users/emrevona/)
 * (@emrevona)
 * [4 years, 5 months ago](https://wordpress.org/support/topic/clear-cache-after-automatic-updates/#post-15190244)
 * why should I remove the isset($options[‘plugins’]) condition? $options[‘plugins’]
   has already exist.

Viewing 15 replies - 1 through 15 (of 21 total)

1 [2](https://wordpress.org/support/topic/clear-cache-after-automatic-updates/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/clear-cache-after-automatic-updates/page/2/?output_format=md)

The topic ‘Clear Cache after Automatic Updates’ is closed to new replies.

 * ![](https://ps.w.org/wp-fastest-cache/assets/icon-256x256.png?rev=2064586)
 * [WP Fastest Cache - WordPress Cache Plugin](https://wordpress.org/plugins/wp-fastest-cache/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wp-fastest-cache/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wp-fastest-cache/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-fastest-cache/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-fastest-cache/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-fastest-cache/reviews/)

## Tags

 * [clear cache](https://wordpress.org/support/topic-tag/clear-cache/)

 * 21 replies
 * 2 participants
 * Last reply from: [Emre Vona](https://wordpress.org/support/users/emrevona/)
 * Last activity: [4 years, 5 months ago](https://wordpress.org/support/topic/clear-cache-after-automatic-updates/page/2/#post-15190837)
 * Status: resolved