• The plugin is setting DONOTCACHEPAGE const on homepage causing some major performance issues for us.

    I had a search through code and I am guessing is might be issue in: wp-content/plugins/woocommerce-cart-stock-reducer/includes/class-woocommerce-cart-stock-reducer.php

    line 1002:

    // Make sure this page is not cached
    WC_Cache_Helper::set_nocache_constants();

    We have a lot of CPU intensive code on homepage so it is last page we want to miss the cache.

    Any idea why it’s triggering on homepage?

Viewing 11 replies - 1 through 11 (of 11 total)
  • Plugin Author James Golovich

    (@jamesgol)

    Is there anything related to a WooCommerce product (that is managed stock) on the homepage?

    Thread Starter CodeMonkeyBanana

    (@codemonkeybanana)

    It seems this is also happening on category pages but product pages appear OK.

    I have defined this in template to counteract it for time being:

    define( 'DONOTCACHEPAGE', false );
    define( 'DONOTCACHEOBJECT', false );
    define( 'DONOTCACHEDB', false );
    Plugin Author James Golovich

    (@jamesgol)

    The code that sets those constants will be added to any page that has a WooCommerce product that has a managed stock. So if you display a product on your main page those constants should be added.

    Thread Starter CodeMonkeyBanana

    (@codemonkeybanana)

    OK, I think I understand. As you change the stock of the item with add to cart then you are making sure any managed stock page isn’t cached. That’s gonna totally nuke performance of our site as no way the server can handle so much traffic without a cache and we manage stock levels for all products.

    So on pages that I am forcing to cache I will need to update the template to read stock via an ajax request or use something like fragment caching on the stock.

    Am I understanding this correctly?

    Plugin Author James Golovich

    (@jamesgol)

    Anytime a product’s status or inventory quantity is checked it is going to set the nocache headers. There probably should be a way to configure when to do that but it’s not setup that way currently.

    Thread Starter CodeMonkeyBanana

    (@codemonkeybanana)

    Yes, it would be very helpful if you could wrap the definitions in an option check so it was possible to disable it without forking or manually specifying in template.

    I am assuming that woocommerces normal behaviour is that when an order goes through it invalidates the page cache of all items on the order so stock shows correctly updated.

    As you are modifying stock on add to cart wouldn’t it be a better approach to set the stock and then specifically invalidate the cache on that page?

    That would allow page caching to work and would be a massive performance increase.

    Thread Starter CodeMonkeyBanana

    (@codemonkeybanana)

    Is there an action I can use that fires after your code has modified the stock that has the product in scope I could use to invalidate the cache of that specific product?

    Plugin Author James Golovich

    (@jamesgol)

    Regarding caching, I believe WooCommerce by default only says to not cache the account, cart, and checkout pages. It will allow product pages to be cached.

    I’ll put it on the todo list to allow more granular control over the caching, but I do not know when I will have available free time to work on it. I’m always open to code contributions.

    Thread Starter CodeMonkeyBanana

    (@codemonkeybanana)

    OK, do you have a git repo or just the SVN?

    Plugin Author James Golovich

    (@jamesgol)

    I just created an issue in the github tracker. https://github.com/jamesgol/woocommerce-cart-stock-reducer/issues/80

    Plugin Author James Golovich

    (@jamesgol)

    I added a WordPress filter ‘wc_csr_set_nocache’ that you can use to return false if you don’t want the nocache constants to be set.

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘Plugin prevents homepage from caching’ is closed to new replies.