Title: programatically delete cache entry
Last modified: August 22, 2016

---

# programatically delete cache entry

 *  Resolved [gstan07](https://wordpress.org/support/users/gstan07/)
 * (@gstan07)
 * [11 years, 4 months ago](https://wordpress.org/support/topic/programatically-delete-cache-entry/)
 * I use wp fragment cache on my website this way:
 * if ( ! WP_Fragment_Cache::output( “photo_gallery_page”, 600 ) ){
 * //cache galllery page
 * WP_Fragment_Cache::store();
    }
 * If i want to delete that cache entry before it expires, what method should i 
   call?
    I was thinking on something like: WP_Fragment_Cache::purge( “photo_gallery_page”)
   but id does not seem to work.
 * What am i doing wrong?
 * Thanks
 * [https://wordpress.org/plugins/wp-fragment-cache/](https://wordpress.org/plugins/wp-fragment-cache/)

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

 *  Plugin Author [mariuspass](https://wordpress.org/support/users/mariuspass/)
 * (@mariuspass)
 * [11 years, 4 months ago](https://wordpress.org/support/topic/programatically-delete-cache-entry/#post-5686802)
 * You can’t delete just one fragment, the [purge function](https://github.com/mariuspass/wp-fragment-cache/blob/master/public/class-wp-fragment-cache.php#L397)
   deletes all the fragments, also that function takes no argument.
 *  Thread Starter [gstan07](https://wordpress.org/support/users/gstan07/)
 * (@gstan07)
 * [11 years, 4 months ago](https://wordpress.org/support/topic/programatically-delete-cache-entry/#post-5686803)
 * I don’t know how many have such use cases but maybe it woul help to include such
   a thing on the next releases.
    Thanks for your answer.
 *  [Znuff](https://wordpress.org/support/users/znuff/)
 * (@znuff)
 * [10 years, 9 months ago](https://wordpress.org/support/topic/programatically-delete-cache-entry/#post-5687071)
 * I have actually made a change to my local copy of WP_Fragment_Cache that can 
   clear individual cache entries.
 * I’ve added a new parameter to ::output(), that will store cache fragments with“
   absolute key names” – this will store fragments without the usual file name/path
   and line number, instead it will store it using the actual provided key name.
 * Then I added a ::remove() function that will take an absolute key name and will
   remove the key from the cache.
 * This is useful to hook into your theme for specific events (ie: when a comment
   is added, a post is changed etc.), without having to purge the whole cache (why
   update the whole cache when just a specific fragment changes?).
 * I would commit it to the main code, but I’m afraid the quality of my documentation
   is not on par with mariuspass’.
 *  Plugin Author [mariuspass](https://wordpress.org/support/users/mariuspass/)
 * (@mariuspass)
 * [10 years, 9 months ago](https://wordpress.org/support/topic/programatically-delete-cache-entry/#post-5687072)
 * > I would commit it to the main code, but I’m afraid the quality of my documentation
   > is not on par with mariuspass’.
 * Please make a pull request on [github repo](https://github.com/mariuspass/wp-fragment-cache).

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

The topic ‘programatically delete cache entry’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/wp-fragment-cache.svg)
 * [WP Fragment Cache](https://wordpress.org/plugins/wp-fragment-cache/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wp-fragment-cache/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wp-fragment-cache/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-fragment-cache/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-fragment-cache/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-fragment-cache/reviews/)

## Tags

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

 * 4 replies
 * 3 participants
 * Last reply from: [mariuspass](https://wordpress.org/support/users/mariuspass/)
 * Last activity: [10 years, 9 months ago](https://wordpress.org/support/topic/programatically-delete-cache-entry/#post-5687072)
 * Status: resolved