Title: Calling the purge programmatically
Last modified: November 15, 2020

---

# Calling the purge programmatically

 *  Resolved [Vincent Poirier](https://wordpress.org/support/users/magikweb/)
 * (@magikweb)
 * [5 years, 6 months ago](https://wordpress.org/support/topic/calling-the-purge-programmatically/)
 * Hello,
    We made a “Master flush” button to simplify the different levels of caching.
   It currently flushes WP Rocket and CloudFlare (through its API).
 * How can we programmatically flush SiteGround’s SuperCacher programmatically? (
   Purge SG Cache)

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

 *  [jetxpert](https://wordpress.org/support/users/jetxpert/)
 * (@jetxpert)
 * [5 years, 6 months ago](https://wordpress.org/support/topic/calling-the-purge-programmatically/#post-13665345)
 * [@magikweb](https://wordpress.org/support/users/magikweb/),
 * According to [this article](https://docs.wp-rocket.me/article/115-can-i-use-wp-rocket-with-sg-optimizer),
   when you purge WP Rocket’s cache, SG Optimizer’s cache is purged automatically.
 * Based on the above, your “Master” flush button should also be flushing SG Optimizer’s
   cache. If not so, I would contact WP Rocket as well to make sure their current
   plugin code is current with SG Optimizer’s.
 * Cheers!
 *  Thread Starter [Vincent Poirier](https://wordpress.org/support/users/magikweb/)
 * (@magikweb)
 * [5 years, 6 months ago](https://wordpress.org/support/topic/calling-the-purge-programmatically/#post-13665523)
 * Thank you! We never knew and always cleared both individually. That’s really 
   nice.
 * We’ll confirm with WP Rocket just to make sure and move one. 🙂
 *  Thread Starter [Vincent Poirier](https://wordpress.org/support/users/magikweb/)
 * (@magikweb)
 * [5 years, 6 months ago](https://wordpress.org/support/topic/calling-the-purge-programmatically/#post-13665546)
 * Marking as resolved.
 *  Plugin Author [Stanimir Stoyanov](https://wordpress.org/support/users/sstoqnov/)
 * (@sstoqnov)
 * SiteGround Representative
 * [5 years, 6 months ago](https://wordpress.org/support/topic/calling-the-purge-programmatically/#post-13667030)
 * Hey [@magikweb](https://wordpress.org/support/users/magikweb/)
 * We have a helper function `sg_cachepress_purge_cache` that you can use to purge
   the cache.
 * Regards,
    Stanimir
 *  [Marco1970](https://wordpress.org/support/users/marco1970/)
 * (@marco1970)
 * [5 years, 4 months ago](https://wordpress.org/support/topic/calling-the-purge-programmatically/#post-13989130)
 * Hi Stanimir,
 * sorry to piggy back here, but I am after a definitive answer, and you being the
   plugin developer will definitely help:
 * I need to clear the whole SG cache stack (dynamic + memcache) programmatically
   from an external script, and I managed to do so using the helper function above
   from within my functions.php, with the help of a GET parameter (I know, not super
   elegant, but it works).
 * BUT… in my very very humble opinion, it does not have the same effect as clicking‘
   Purge SG Cache’ from admin backend, which definitely clears the whole cache stack.
   Simple test:
 * – I run a script that changes the woocommerce product prices via a DB operation,
   and then invokes the sg_cachepress_purge_cache() via the get param trick described
   above (and I can see that the helper function returns true, meaning it has worked
   OK)
    – I go to the website on Safari browser, but the prices are still the old
   ones, even if I do a hard-reload (Shift + Reload), and/or click ‘Empty Caches’
   under Safari Develop menu – I go to the site backend admin in Chrome, and click‘
   Purge SG Cache’ – Go back to website on Safari, do a simple standard reload, 
   and prices are updated
 * So clearly there is something missing…
 * Is that memcache? does sg_cachepress_purge_cache() flush memcache as well?
 * Is there anything else I should invoke beside sg_cachepress_purge_cache()?
 * TY in advance for any help
 * m
 *  Plugin Author [Stanimir Stoyanov](https://wordpress.org/support/users/sstoqnov/)
 * (@sstoqnov)
 * SiteGround Representative
 * [5 years, 4 months ago](https://wordpress.org/support/topic/calling-the-purge-programmatically/#post-13990024)
 * Hey [@marco1970](https://wordpress.org/support/users/marco1970/)
 * We will add a new helper function in the next version, which will purge everything(
   Dynamic cache, Memcached & combined/minified assets ).
 * Regards,
    Stanimir
 *  [Marco1970](https://wordpress.org/support/users/marco1970/)
 * (@marco1970)
 * [5 years, 4 months ago](https://wordpress.org/support/topic/calling-the-purge-programmatically/#post-13990775)
 * Hi Stanimir,
 * great news, thanks!!!
 *  [Marco1970](https://wordpress.org/support/users/marco1970/)
 * (@marco1970)
 * [5 years, 3 months ago](https://wordpress.org/support/topic/calling-the-purge-programmatically/#post-14108023)
 * Hi Stanimir,
 * did you guys manage to add the new helper function to purge all?
 * M
 *  Plugin Author [Stanimir Stoyanov](https://wordpress.org/support/users/sstoqnov/)
 * (@sstoqnov)
 * SiteGround Representative
 * [5 years, 3 months ago](https://wordpress.org/support/topic/calling-the-purge-programmatically/#post-14114942)
 * Hey [@marco1970](https://wordpress.org/support/users/marco1970/)
 * Yes, the helper function has been added: `sg_cachepress_purge_everything`
 * You can try it if you have updated to the latest version.
 * Your feedback will be highly appreciated.
 * Regards,
    Stanimir
 *  [Marco1970](https://wordpress.org/support/users/marco1970/)
 * (@marco1970)
 * [5 years, 3 months ago](https://wordpress.org/support/topic/calling-the-purge-programmatically/#post-14114952)
 * AWESOME, thanks!!
 * will test ASAP and report
 * TY
 * m
 *  [jetxpert](https://wordpress.org/support/users/jetxpert/)
 * (@jetxpert)
 * [5 years, 3 months ago](https://wordpress.org/support/topic/calling-the-purge-programmatically/#post-14117595)
 * **[@sstoqnov](https://wordpress.org/support/users/sstoqnov/),**
 * Thank you for the information. Please clarify:
 * (1) What version of SG Optimizer incorporates the new helper function?
 * (2) Are you saying that when we click “Purge SG Cache” (WP backend) we are purging
   static, dynamic, and memcached?
 * Again, thank you.
 * **[@marco1970](https://wordpress.org/support/users/marco1970/),**
 * Looking forward to your test results. Also, can you share the process or steps
   you followed?
 * Thank you.
 *  [Rahul](https://wordpress.org/support/users/laddoo/)
 * (@laddoo)
 * [4 years, 11 months ago](https://wordpress.org/support/topic/calling-the-purge-programmatically/#post-14623680)
 * Is there any inbuilt cron to clear all cache automatically ?

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

The topic ‘Calling the purge programmatically’ is closed to new replies.

 * ![](https://ps.w.org/sg-cachepress/assets/icon-256x256.gif?rev=2971889)
 * [Speed Optimizer - The All-In-One Performance-Boosting Plugin](https://wordpress.org/plugins/sg-cachepress/)
 * [Support Threads](https://wordpress.org/support/plugin/sg-cachepress/)
 * [Active Topics](https://wordpress.org/support/plugin/sg-cachepress/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/sg-cachepress/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/sg-cachepress/reviews/)

## Tags

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

 * 12 replies
 * 5 participants
 * Last reply from: [Rahul](https://wordpress.org/support/users/laddoo/)
 * Last activity: [4 years, 11 months ago](https://wordpress.org/support/topic/calling-the-purge-programmatically/#post-14623680)
 * Status: resolved