Title: Force multisite clear cache
Last modified: January 18, 2021

---

# Force multisite clear cache

 *  Resolved [Ced](https://wordpress.org/support/users/cedriccharles/)
 * (@cedriccharles)
 * [5 years, 4 months ago](https://wordpress.org/support/topic/force-multisite-clear-cache/)
 * Hello there 🙂
 * I have a WordPress Multisite that contains 1 primary site and 10+ sub-sites. 
   The content of the sub-sites directly depends on the primary site. My client 
   only create contents on the primary site, than the content is dispatched (with
   Three WP Broadcast plugin: [https://wordpress.org/plugins/threewp-broadcast/](https://wordpress.org/plugins/threewp-broadcast/))
 * When my client create a post on the primary site, the LiteSpeed cache is cleared
   on the primary site, but not on the sub-sites. So the new post is not showing
   on the multiple sub-sites. I would like to have a button in the admin bar next
   to the current Litespeed button (or a new item in the current button) which allow
   my client to “Clear all sites/sub-sites cache”.
 * How can I achieve that?
 * Thank you in advance,
    Cedric

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

 *  [usabe](https://wordpress.org/support/users/usabe/)
 * (@usabe)
 * [5 years, 4 months ago](https://wordpress.org/support/topic/force-multisite-clear-cache/#post-13924889)
 * Hi, Cedric,
 * I just did a forum search, and found that actually you proposed this question
   a while ago. Please refer to this post: [https://wordpress.org/support/topic/purging-all-cache-for-whole-multisite-network/](https://wordpress.org/support/topic/purging-all-cache-for-whole-multisite-network/)
 * To achieve what you want, I guess you can make the button just to implement the
   second solution provided in the post above.
 * **second solution , create a PHP file with code
    <?php header(‘x-litespeed-purge:\*’);
   access it will result purge all as well.
 * Best regards
 *  Plugin Support [qtwrk](https://wordpress.org/support/users/qtwrk/)
 * (@qtwrk)
 * [5 years, 4 months ago](https://wordpress.org/support/topic/force-multisite-clear-cache/#post-13925150)
 * Hi,
 * actually if you purge it at network admin page, it purges for all subsites
 * Best regards,
 *  Thread Starter [Ced](https://wordpress.org/support/users/cedriccharles/)
 * (@cedriccharles)
 * [5 years, 4 months ago](https://wordpress.org/support/topic/force-multisite-clear-cache/#post-13925963)
 * Hi there 🙂 !
 * Thank you for your answers.
    [@qtwrk](https://wordpress.org/support/users/qtwrk/)
   [@usabe](https://wordpress.org/support/users/usabe/) unfortunately, my client
   doesn’t access the network admin page. He has only access to the primary site
   admin page and wants to be able to clear all the cache by himself. I guess if
   that button exists on the network admin page, I can “copy” the code to put it
   on the primary site admin page 🙂 ? Can you tell me how or where this code is
   located in your plugin?
 * Thank you in advance,
    Cedric
 *  Plugin Support [qtwrk](https://wordpress.org/support/users/qtwrk/)
 * (@qtwrk)
 * [5 years, 4 months ago](https://wordpress.org/support/topic/force-multisite-clear-cache/#post-13930106)
 * Hi,
 * simplest way would be what usabe suggested
 * create a PHP file with content
 *     ```
       <?php
       header('x-litespeed-purge:*');
       ```
   
 * then access it
 * of course you can put some further verification over it , like check against 
   IP or something.
 * if you want to do it within WP
 * try this code
 *     ```
       <?php 
       define( 'WP_USE_THEMES', true );
       require( './wp-load.php' );
   
        if (defined('LSCWP_V'))
       {
               define( 'LSWCP_EMPTYCACHE', true);
               do_action( 'litespeed_purge_all' );
       }
       ```
   
 * Best regards,
 *  Thread Starter [Ced](https://wordpress.org/support/users/cedriccharles/)
 * (@cedriccharles)
 * [5 years, 4 months ago](https://wordpress.org/support/topic/force-multisite-clear-cache/#post-13932170)
 * Hi and thanks.
    Can’t this be done exactly like what you do for the network link
   in the admin bar?
 * Kind regards,
    Cedric
 *  Plugin Support [qtwrk](https://wordpress.org/support/users/qtwrk/)
 * (@qtwrk)
 * [5 years, 4 months ago](https://wordpress.org/support/topic/force-multisite-clear-cache/#post-13938999)
 * Hi,
 * yes
 * you can add this
 * `define( 'LSWCP_EMPTYCACHE', true);`
 * to wp-config.php
 * then a purge all from any of sub-site will cause purge all on entire network
 * Best regards,
 *  Thread Starter [Ced](https://wordpress.org/support/users/cedriccharles/)
 * (@cedriccharles)
 * [5 years, 4 months ago](https://wordpress.org/support/topic/force-multisite-clear-cache/#post-13944121)
 * Hello 🙂
 * Oh ok, simply adding `define( 'LSWCP_EMPTYCACHE', true);` in wp-config.php will
   purge all caches everytime “Purge all” is hit, whatever site it’s hit?
 * Kind regards
 *  Plugin Support [qtwrk](https://wordpress.org/support/users/qtwrk/)
 * (@qtwrk)
 * [5 years, 4 months ago](https://wordpress.org/support/topic/force-multisite-clear-cache/#post-13944125)
 * yes
 * it should be purge all on entire network from any of sites
 *  Thread Starter [Ced](https://wordpress.org/support/users/cedriccharles/)
 * (@cedriccharles)
 * [5 years, 4 months ago](https://wordpress.org/support/topic/force-multisite-clear-cache/#post-13944130)
 * Perfect 🙂 Thank you! (what a fast answer :p)
 *  Thread Starter [Ced](https://wordpress.org/support/users/cedriccharles/)
 * (@cedriccharles)
 * [5 years, 4 months ago](https://wordpress.org/support/topic/force-multisite-clear-cache/#post-13944155)
 * One more question: the “Three WP Broadcast” plugin uses a “Queue” system to send
   posts created in one sub-site to another sub-site. Sometimes, I have 50 posts
   that should be broadcasted, so I have 50 posts in the queue. When they are all
   broadcasted, the plugin needs to empty all the caches.
 * The plugin developer (Edward, Plainview Plugins: [edward@plainviewplugins.com](https://wordpress.org/support/topic/force-multisite-clear-cache/edward@plainviewplugins.com?output_format=md))
   told me he can launch some code when the queue is fully processed, but require
   me to tell him the code he should trigger. Could you please help with this?
 * Kind regards,
    Cedric
 *  Plugin Support [qtwrk](https://wordpress.org/support/users/qtwrk/)
 * (@qtwrk)
 * [5 years, 4 months ago](https://wordpress.org/support/topic/force-multisite-clear-cache/#post-13944180)
 * Hi,
 * please kindly tell him following :
 *     ```
       if (defined('LSCWP_V')) {
   
       define( 'LSWCP_EMPTYCACHE', true);
       do_action( 'litespeed_purge_all' );
       # above 2 lines to purge entire network
   
       do_action( 'litespeed_purge_post', $post_id );
       #or post a specific page by post_id
   
       }
       ```
   
 * more detail [here](https://docs.litespeedtech.com/lscache/lscwp/api/#purge)
 * Best regards,
    -  This reply was modified 5 years, 4 months ago by [qtwrk](https://wordpress.org/support/users/qtwrk/).

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

The topic ‘Force multisite clear cache’ is closed to new replies.

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

## Tags

 * [multisite](https://wordpress.org/support/topic-tag/multisite/)
 * [purge all](https://wordpress.org/support/topic-tag/purge-all/)

 * 11 replies
 * 3 participants
 * Last reply from: [qtwrk](https://wordpress.org/support/users/qtwrk/)
 * Last activity: [5 years, 4 months ago](https://wordpress.org/support/topic/force-multisite-clear-cache/#post-13944180)
 * Status: resolved