Clear the category cache when editing the product




Wordpress LScache Plugin: Clear the category cache when editing the product

Last Updated on: Wed, 15 Apr 2026 00:00:02
Hi I have a shop built with WooCommerce When I edit a product, the cache of all product categories related to that product as well as its parent category is cleared Although I did not check all the checkboxes in the cache clearing settings. Because I edit my products many times, this causes the site cache to be cleared quickly and the site to have a slow problem due to clear cache. How can I prevent the category cache from being cleared while editing the product? Hi, well , its by design and hard-coded that way , to purge related category pages when edit/publish a product Best regards, please try , add this at top of your themes functions.php add_action(woocommerce_update_product, lscwp_suppress_purge_product_update, 10, 2) function lscwp_suppress_purge_product_update($product_id, $product) ob_start( function($buffer) use ($product_id) @header( X-LiteSpeed-Purge: . LSWCP_TAG_PREFIX . _Po. . $product_id ) return $buffer ) this should surpress purge call when edit product. this code doesnt work on WordPress multisite network , only individual/single WP please do double test , this was not how plugin was deisnged to work , make sure you dont see out-dated content somewhere , like you raised price , product page shows new price, while category page is showing old price or something like that ? I tested this code Very good and when editing the product, the categories do not clear cache But something better can be done Before adding this code, when editing a product, the product category cache and the parent category cache were removed. As well as other children in the parent category But the principle is that only this category and the parent category should be erased. After I use this code, the cache of the category itself will not be deleted. I have no problem deleting the parent cache and the category itself, and it is even better to delete them so that the information is up to date. My problem is that the other children in the parent category are not erased Because there is no need to update their information and we may have another 40 children yes , as I have explained , this will make it only to purge the product page itself but no other pages since one product can be linked to multiple categories , when you use some function like get_the_terms() or wp_get_post_terms() , it will return multiple categories and there is no way to determinate which one is parent category or which one is child category



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



Reference