Title: How to clear cache programatically ?
Last modified: November 29, 2016

---

# How to clear cache programatically ?

 *  [Prafulla Kumar Sahu](https://wordpress.org/support/users/prafulla/)
 * (@prafulla)
 * [9 years, 5 months ago](https://wordpress.org/support/topic/how-to-clear-cache-programatically/)
 * I want to clear cache of a page ( single product page ) when ever the stock status
   changes, Is there any way I can clear and regenerate cache for single-product
   page on `woocommerce_product_set_stock` hook,
 * I tried
 *     ```
       add_action( 'woocommerce_product_set_stock', 'le_product_stock_status_update' );
       if ( is_plugin_active( 'wp-super-cache/wp-cache.php' ) ){
       function le_product_stock_status_update($post_id = '') {
   
               global $blog_cache_dir, $wp_cache_object_cache;
   
               if ( $wp_cache_object_cache ) {
                   reset_oc_version();
               } else {
                   prune_super_cache( $blog_cache_dir, true );
                   prune_super_cache( get_supercache_dir(), true );
               }
           }
       }
       ```
   
 * .

The topic ‘How to clear cache programatically ?’ is closed to new replies.

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

## Tags

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

 * 0 replies
 * 1 participant
 * Last reply from: [Prafulla Kumar Sahu](https://wordpress.org/support/users/prafulla/)
 * Last activity: [9 years, 5 months ago](https://wordpress.org/support/topic/how-to-clear-cache-programatically/)
 * Status: not resolved