Title: clear cache by code
Last modified: August 30, 2016

---

# clear cache by code

 *  Resolved [igornn](https://wordpress.org/support/users/igornn/)
 * (@igornn)
 * [10 years, 8 months ago](https://wordpress.org/support/topic/clear-cache-by-code/)
 * Hi,
    great plugin, Thanks!
 * now the question
 * i am using multisite with more than 50 sites.
    when i make some changes in the
   template file, i need to go each site and click on clear cache button.
 * how can i just loop over all sites and make clear cache by code?
 * Thanks
 * [https://wordpress.org/plugins/cachify/](https://wordpress.org/plugins/cachify/)

Viewing 1 replies (of 1 total)

 *  [Pascal Birchler](https://wordpress.org/support/users/swissspidy/)
 * (@swissspidy)
 * [10 years, 8 months ago](https://wordpress.org/support/topic/clear-cache-by-code/#post-6587024)
 * Hi there
 * Thanks for reaching out. You could use something like this to clear the cache
   for all sites:
 *     ```
       if ( is_multisite() && class_exists( 'Cachify' ) ) {
       	foreach (wp_get_sites() as $site) {
       		switch_to_blog($site->bog_id);
       		Cachify::flush_total_cache();
       		restore_current_blog();
       	}
       }
       ```
   
 * Note: This query is untested. You should be aware that looping through all sites
   and deleting their cache could take a while. However, with 50 sites that shouldn’t
   be a big deal.

Viewing 1 replies (of 1 total)

The topic ‘clear cache by code’ is closed to new replies.

 * ![](https://ps.w.org/cachify/assets/icon-256x256.png?rev=2505413)
 * [Cachify](https://wordpress.org/plugins/cachify/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/cachify/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/cachify/)
 * [Active Topics](https://wordpress.org/support/plugin/cachify/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/cachify/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/cachify/reviews/)

 * 1 reply
 * 2 participants
 * Last reply from: [Pascal Birchler](https://wordpress.org/support/users/swissspidy/)
 * Last activity: [10 years, 8 months ago](https://wordpress.org/support/topic/clear-cache-by-code/#post-6587024)
 * Status: resolved