0

I looked for a solutin like more than hour, but not chance. There is a function to reset cache of a specific page manually? I'm using wp super cache.

I'm updating some posts meta values using API, and I want when I update something, I reset the cache of this page only. There is a function for that?

Thanks

1 Answer 1

3

The function you're looking for is wpsc_delete_post_cache()

$post_id = 123;
wpsc_delete_post_cache($post_id);
4
  • if I can ask, what is the difference with wp_cache_post_change() function?
    – CodingHero
    Commented Nov 7, 2017 at 19:58
  • 2
    While not formally declared as such in the codebase, wp_cache_post_change() is more like an event handler. It responds to post edits. And while it does much the same thing as wpsc_delete_post_cache(), there are several runtime considerations made by that function, making it slightly less desirable if you're intention is explicitly to clear a specific post ID. Calling wp_cache_post_change() may or may not result in the cache being cleared, or it may result in multiple areas of the cache being cleared. It considers constants, actions, and customizable filters.
    – jaswrks
    Commented Nov 7, 2017 at 20:24
  • Note that wpsc_delete_post_cache() also deletes the post author's posts page.
    – jaswrks
    Commented Nov 7, 2017 at 20:26
  • 1
    ok, I didn't understand the last phrase : "deletes the post author's posts page.". what do you mean with posts pages? it delete cache of all posts of that author?
    – CodingHero
    Commented Nov 7, 2017 at 20:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.