Purge cache from php script




Wordpress LScache Plugin: Purge cache from php script

Last Updated on: Wed, 15 Apr 2026 00:00:02
Hello, I am using a php script to update prices and stock for woocommerce eshop. My issue, is that i have to Purge the litespeed cache manually, so the changes to be affected for the visitors of the site. Can i call a method to purge the cache from my php file? Or any other way to do it? Thanks in advantage, Hi @ntoum, Yes you can, if you want to purge a single page, you can use LiteSpeed_Cache::get_instance()->purge_all() to purge all, or LiteSpeed_Cache::get_instance()->purge_single_post($post_id) to purge one post in v1.1.2.2. Please note, in v1.1.3, we will change the structure and add a new API class, at that time, you can use a easier and simpler way to do this. If your script is not loaded from WP, you can follow this wiki: https://www.litespeedtech.com/support/wiki/doku.php/litespeed_wiki:cache:developer_guide:response_headers send the purge header manually to server directly. Hello, Thank you very much for your answer! I tried it, and seems to working. If i will have any problem, ill write it here. By the way, is there any documantion with all php methods that i can use? My script is loaded from WP (actually calling wp-load.php). Hi, @ntoum We do have this wiki that may help, but its slightly out-of-date, and is very likely to be changing with the next release. You can take a look for reference, but Id hold off doing any major development with it until we get it freshly-updated (should be soon!): https://www.litespeedtech.com/support/wiki/doku.php/litespeed_wiki:cache:lscwp:api Hope this helps! Lisa @ LiteSpeed Hello, NiceOkey, i will use only the method above, because i am updating daily a lot of products through script, and i am waiting for your update for further major development. Thank you very much for your helpOur pleasure. Happy caching!



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



Reference