How to trigger a cache purge from another plugin?




Wordpress LScache Plugin: How to trigger a cache purge from another plugin?

Last Updated on: Wed, 15 Apr 2026 00:00:02
Hi, just a quick question. How do I trigger a complete cache purge from within another plugin? For example, for W3TC I can do this: # Purge WP Super Cache if (function_exists(wp_cache_clear_cache)) do_action( wp_cache_clear_cache ) Is there a similar method I can use on your plugin? Kind Regards, Raul Peixoto Hi @alignak Our list of third party functions are in litespeed-cache/includes/class-litespeed-cache-tags.php If you are looking to purge everything on the site, you can do if (class_exists(LiteSpeed_Cache_Tags)) LiteSpeed_Cache_Tags::add_purge_tag( ) However, if youd like, you can also tag pages with an identifier so that you can take advantage of the smart purge feature. When you know a page has a certain feature, you can tag it. E.g. a gallery plugin might know a page has gallery id 4. They would do: if (class_exists(LiteSpeed_Cache_Tags)) LiteSpeed_Cache_Tags::add_cache_tag(g. . get_gallery_id()) // adds g.4 Then later, when they need to purge: if (class_exists(LiteSpeed_Cache_Tags)) LiteSpeed_Cache_Tags::add_purge_tag(g. . get_gallery_id()) Let me know if you have any more questions about this! We have a wiki article here, but I can also answer any questions here. Cheers, Kevin Thank you very much, My plugin is the fast velocity minify and it does merging of js and css files. When those files are purged, other cache plugins need to be purged completely also, so for my case I really need to purge everything. This is exactly what I needed, thanks. Raul Ah, someone just asked about your plugin! If youd like, we can validate your modifications and add your plugin to our list of compatible plugins when its available. Let us know if you run into any problems! Cheers, Kevin Indeed, someone also requested for you plugin to be supported too. Ill be adding support on the next version so that purging my plugin will also purge yours too. It should be up within 24 or 48 hours and Ill let you know if you wish to take a look and test things. Thanks again, Raul Perfect, thanks! Hi Kevin, Ive implemented this a while back and Fast Velocity Minify is already purging LiteSpeed Cache when our purge cache button is pressed. I have a function to purge our cache too, but I dont think its relevant for your plugin, since it purges the whole cache only. Also, if I trigger the cache purge to your plugin, it would double purge mine? so I think we can leave things as they are. Thanks for the earlier tip on how to purge your cache. Hi Raul, Good to know that its working! Thanks for your efforts on getting our plugins working together, Ill be sure to add your plugin to our list of compatible plugins. As for cache purging, the only issue we would come across would be if your plugin changes the paths in any way. If our cached page is expecting a certain url and your plugin already changed the url to something else, thats when wed have issues. If you need anything from us, let us know! Cheers, Kevin I dont think there will be any issues on FVM end, even If we change paths. If the users purge LiteSpeed (partially or full), my plugin will generate new static files as soon as the uncached version is requested on the browser (which will then be used by the full page cache). Likewise, purging FVM cache, will trigger a full purge on LiteSpeed, so we know for sure that there wont be any references left to our old files. If users do not ever purge FVM cache, the old files will expire after 45 days? so thats more than enough time to invalidate the cache. Ill look into making this more efficient, rather than just delete old files after 45 days, however, I dont think there will be a problem. Thanks for adding us to the compatible plugins list. Your plugin is also on mine too. Regards, Raul



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



Reference