Title: Automatic Cache Clears
Last modified: February 15, 2017

---

# Automatic Cache Clears

 *  Resolved [conorseed](https://wordpress.org/support/users/conorseed/)
 * (@conorseed)
 * [9 years, 3 months ago](https://wordpress.org/support/topic/automatic-cache-clears/)
 * Hey 🙂 I just wondered if there was a function I could use / reference to set
   up a daily purging of the entire cache (probably using WP Cron)??
 * I know how to setup the cron, I just need to know if there’s a function.
 * Thanks!

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

 *  [thellimist](https://wordpress.org/support/users/furkan811/)
 * (@furkan811)
 * [9 years, 3 months ago](https://wordpress.org/support/topic/automatic-cache-clears/#post-8807508)
 * Yes, here is an example of the hooks you can use for purging cache
 * [https://github.com/cloudflare/Cloudflare-WordPress/blob/master/cloudflare.loader.php#L48-L61](https://github.com/cloudflare/Cloudflare-WordPress/blob/master/cloudflare.loader.php#L48-L61)
 * You can find the implementations of the functions here
 * [https://github.com/cloudflare/Cloudflare-WordPress/blob/master/src/WordPress/Hooks.php](https://github.com/cloudflare/Cloudflare-WordPress/blob/master/src/WordPress/Hooks.php)
 *  Thread Starter [conorseed](https://wordpress.org/support/users/conorseed/)
 * (@conorseed)
 * [9 years, 3 months ago](https://wordpress.org/support/topic/automatic-cache-clears/#post-8809488)
 * Thanks! I’ll see if I can get this to do what I want 🙂
 *  [jwineman](https://wordpress.org/support/users/jwineman/)
 * (@jwineman)
 * [9 years, 3 months ago](https://wordpress.org/support/topic/automatic-cache-clears/#post-8809538)
 * [@conorseed](https://wordpress.org/support/users/conorseed/),
 * You can instantiate a WordPressClientAPI which is the class we use to send API
   calls to Cloudflare.com like this:
    [https://github.com/cloudflare/Cloudflare-WordPress/blob/master/src/WordPress/Hooks.php#L21-L26](https://github.com/cloudflare/Cloudflare-WordPress/blob/master/src/WordPress/Hooks.php#L21-L26)
 *     ```
               $this->config = new Integration\DefaultConfig(file_get_contents(CLOUDFLARE_PLUGIN_DIR.'config.js', true));
               $this->logger = new Integration\DefaultLogger($this->config->getValue('debug'));
               $this->dataStore = new DataStore($this->logger);
               $this->integrationAPI = new WordPressAPI($this->dataStore);
               $this->integrationContext = new Integration\DefaultIntegration($this->config, $this->integrationAPI, $this->dataStore, $this->logger);
               $this->api = new WordPressClientAPI($this->integrationContext);
       ```
   
 * You can call purge cache like this:
    [https://github.com/cloudflare/Cloudflare-WordPress/blob/master/src/WordPress/WordPressClientAPI.php#L38](https://github.com/cloudflare/Cloudflare-WordPress/blob/master/src/WordPress/WordPressClientAPI.php#L38)
 *     ```
       $this->api->zonePurgeCache($zoneId);
       ```
   
 * Thanks,
    John

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

The topic ‘Automatic Cache Clears’ is closed to new replies.

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

 * 3 replies
 * 3 participants
 * Last reply from: [jwineman](https://wordpress.org/support/users/jwineman/)
 * Last activity: [9 years, 3 months ago](https://wordpress.org/support/topic/automatic-cache-clears/#post-8809538)
 * Status: resolved