Title: Programmatically clearing cache not working
Last modified: January 6, 2025

---

# Programmatically clearing cache not working

 *  Resolved [Andy Macaulay-Brook](https://wordpress.org/support/users/andymacb/)
 * (@andymacb)
 * [1 year, 4 months ago](https://wordpress.org/support/topic/programmatically-clearing-cache-not-working/)
 * Hi, following this support reply I’ve added this code to functions.php:
 * `add_action( 'save_post', 'wd_docket_cache_flush', 10, 3 );`
 * `function wd_docket_cache_flush( $post_id, $post, $update ) {
   wp_cache_flush();}
 * But when I create and save a new page and then check the Docket Cache config 
   page, the caches aren’t being cleared. Am I missing something?
 * Thanks.

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

 *  Thread Starter [Andy Macaulay-Brook](https://wordpress.org/support/users/andymacb/)
 * (@andymacb)
 * [1 year, 4 months ago](https://wordpress.org/support/topic/programmatically-clearing-cache-not-working/#post-18228126)
 * Sorry, this is the support answer I used [https://wordpress.org/support/topic/how-to-flush-object-cache-programmatically/](https://wordpress.org/support/topic/how-to-flush-object-cache-programmatically/)
 *  Plugin Author [Nawawi Jamili](https://wordpress.org/support/users/nawawijamili/)
 * (@nawawijamili)
 * [1 year, 4 months ago](https://wordpress.org/support/topic/programmatically-clearing-cache-not-working/#post-18228260)
 * Hi there,
 *  Please try this code instead [https://gist.github.com/nawawi/808040031e5a42bba5bf152296c10849](https://gist.github.com/nawawi/808040031e5a42bba5bf152296c10849)
 * Download and save to wp-content/mu-plugins/docketcache_flush_when_save_post.php
 * Thanks.
 *  Thread Starter [Andy Macaulay-Brook](https://wordpress.org/support/users/andymacb/)
 * (@andymacb)
 * [1 year, 4 months ago](https://wordpress.org/support/topic/programmatically-clearing-cache-not-working/#post-18229788)
 * Great! That seems to work fine. Thanks. Is all that code going to be OK when 
   the plugin has updates?
 *  Plugin Author [Nawawi Jamili](https://wordpress.org/support/users/nawawijamili/)
 * (@nawawijamili)
 * [1 year, 4 months ago](https://wordpress.org/support/topic/programmatically-clearing-cache-not-working/#post-18230842)
 * > Is all that code going to be OK when the plugin has updates?
 * Yes.
 *  Plugin Author [Nawawi Jamili](https://wordpress.org/support/users/nawawijamili/)
 * (@nawawijamili)
 * [1 year, 4 months ago](https://wordpress.org/support/topic/programmatically-clearing-cache-not-working/#post-18235552)
 * Hi,
 * I’m marking this thread as resolved. Feel free to open a new topic if you have
   further questions.
 * Thanks.

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

The topic ‘Programmatically clearing cache not working’ is closed to new replies.

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

 * 5 replies
 * 2 participants
 * Last reply from: [Nawawi Jamili](https://wordpress.org/support/users/nawawijamili/)
 * Last activity: [1 year, 4 months ago](https://wordpress.org/support/topic/programmatically-clearing-cache-not-working/#post-18235552)
 * Status: resolved