• Resolved jamshiddeveloper

    (@jamshiddeveloper)


    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?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Support qtwrk

    (@qtwrk)

    Hi,

    well , it’s by design and hard-coded that way , to purge related category pages when edit/publish a product

    Best regards,

    • This reply was modified 3 years, 5 months ago by qtwrk.
    Plugin Support qtwrk

    (@qtwrk)

    please try , add this at top of your theme’s 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 doesn’t 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 don’t 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 …

    Thread Starter jamshiddeveloper

    (@jamshiddeveloper)

    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

    Plugin Support qtwrk

    (@qtwrk)

    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

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Clear the category cache when editing the product’ is closed to new replies.