Title: Delete cache via script
Last modified: October 20, 2016

---

# Delete cache via script

 *  [K15Lmk98](https://wordpress.org/support/users/k15lmk98/)
 * (@k15lmk98)
 * [9 years, 7 months ago](https://wordpress.org/support/topic/delete-cache-via-script/)
 * This is an automatic translation
 * I am trying to delete the cache with a script, placed in the WP root. Code:
 * ——————————
 *     ```
       <?Php
   
       require_once("wp-load.php");
   
       include_once('wp-admin/includes/plugin.php');
       if ( is_plugin_active( 'w3-total-cache/w3-total-cache.php' ) ) :
       	echo 'Plugin ACTIVE';
   
       	// Clear all W3 Total Cache
       	$w3_plugin_totalcache->flush_all();
       	echo '<div><p>All <strong>W3 Total Cache</strong> caches successfully emptied.</p></div>';
   
       else :
       	echo 'Plugin DEACTIVATE !!!!!!!!!!!!!!';
   
       endif;
   
       ?>
       ```
   
 * ——————————
 * … but I get the error:
    Plugin ACTIVE Fatal error: Call to a member function 
   flush_all() on null in /home/zanclus6/public_html/cr_w3tc_clear_cache.php on 
   line 10
 * Thank you for the help, Claudio_

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

 *  [Ashok](https://wordpress.org/support/users/bappidgreat/)
 * (@bappidgreat)
 * [9 years, 7 months ago](https://wordpress.org/support/topic/delete-cache-via-script/#post-8335052)
 * Hello [@k15lmk98](https://wordpress.org/support/users/k15lmk98/)
 * You can use just a simple function. So just call the function when you need to
   flush:
 *     ```
       w3tc_flush_all();
       ```
   
 * It is the shortcut for varnish flush. There are some more functions too:
 *     ```
       w3tc_flush_post( $post_id );
       w3tc_flush_posts();
       w3tc_flush_url( $url );
       w3tc_pgcache_flush();
       ```
   
 * You will find more in /wp-content/plugins/w3-total-cache/w3-total-cache-api.php
   file.
 * Have a good day!
 * Cheers
    Ash
 *  Thread Starter [K15Lmk98](https://wordpress.org/support/users/k15lmk98/)
 * (@k15lmk98)
 * [9 years, 7 months ago](https://wordpress.org/support/topic/delete-cache-via-script/#post-8337410)
 * Thanks 1000+, Ash.
 * Topic closed, Claudio_
 *  [Prince_Dhaval](https://wordpress.org/support/users/shethdhaval/)
 * (@shethdhaval)
 * [9 years, 6 months ago](https://wordpress.org/support/topic/delete-cache-via-script/#post-8497138)
 * Hey guys i m using this plugin and it is working good but i dont know if we use
   cache then why its not calling the functions.php file of active theme.
    for example
   people from us can visit the site then they can see some other content and other
   visitor from rest of countries can see different content as well but due to cache
   i can not achieve these if do you have any idea then please let me know
 *  [Tribulant Software](https://wordpress.org/support/users/contrid/)
 * (@contrid)
 * [9 years ago](https://wordpress.org/support/topic/delete-cache-via-script/#post-9117553)
 * [@bappidgreat](https://wordpress.org/support/users/bappidgreat/)
 * Very useful, thank you.
 * To flush the W3 Total Cache object cache, you can use this:
 * `w3tc_objectcache_flush();`
    -  This reply was modified 9 years ago by [Tribulant Software](https://wordpress.org/support/users/contrid/).

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

The topic ‘Delete cache via script’ is closed to new replies.

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

## Tags

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

 * 4 replies
 * 4 participants
 * Last reply from: [Tribulant Software](https://wordpress.org/support/users/contrid/)
 * Last activity: [9 years ago](https://wordpress.org/support/topic/delete-cache-via-script/#post-9117553)
 * Status: not resolved