Whats the code for purging an individual post?




Wordpress LScache Plugin: Whats the code for purging an individual post?

Last Updated on: Wed, 15 Apr 2026 00:00:02
Hi Im using YASR plugin for rating, this one has already have support for WP Rocket plugin cache: each time a visitor vote /update vote for a post, this post is cache purged, like this: add_action(yasr_action_on_visitor_vote, yasr_delete_cache ) add_action(yasr_action_on_update_visitor_vote, yasr_delete_cache) function yasr_delete_cache($post_id) yasr_wp_rocket_support($post_id) function yasr_wp_rocket_support($post_id) if(function_exists(rocket_clean_post)) rocket_clean_post($post_id) Is there something similar in LiteSpeed cache plugin that I can call to purge a specific post identified by its ID? Thanks This topic was modified 5 years ago by pako69. Hi, Pako69. Have a look at our API documentation. Theres a lot you can do. Is there something similar in LiteSpeed cache plugin that I can call to purge a specific post identified by its ID? That would be the LiteSpeed_Cache_API::purge_post($id) function. Yes you can just change the second part in your code to function yasr_delete_cache($post_id) if ( method_exists( LiteSpeed_Cache_API, purge_post ) ) LiteSpeed_Cache_API::purge_post( $post_id ) From our wiki: https://www.litespeedtech.com/support/wiki/doku.php/litespeed_wiki:cache:lscwp:api I tried, but the post dit not seem to be purged I see here: https://wordpress.org/support/topic/improvement-suggestion-for-litespeed-cache-plugin-compatibility/ another syntax : if ( method_exists( LiteSpeed_Cache_API, purge_post ) == true) but I used : if ( method_exists( LiteSpeed_Cache_API, purge_post ) ) Is there any difference? I also read that YASR use WordPress Transients, maybe its a problem? Thanks our cache plugin doesnt generate/clear WordPress Transients cache. When you turn on debug log and do a rating, did you see any log about purge? Hi Its ok now and if you are interested I have made some modifications to this plugin : YASR https://wordpress.org/plugins/yet-another-stars-rating/ to make it compatible with LiteSpeedCache Plugin https://wordpress.org/support/topic/yasr-is-litespeed-cache-plugin-compatible/ Good job! thanks Hi The author has updated his plugin with my mofifications, so now YASR is LSCWP compatible, of course you can try it by yourself and add this plugin to you compatibles plugin list? Thanks Great news! Thanks for the modifications and for letting us know about them



LiteCache Rush: Speed comes from using less, not from doing it faster



Reference