• Resolved JackSim

    (@jacksim)


    I’m using WP Super Cache on my WooCommerce site and it seems to be working quite well out of the box. Thanks to everybody involved!

    For example, when I edit a product (or even just change the stock level of a variable product) that product page cache is correctly reset, as well as the categories the product is in and the homepage. Makes perfect sense.

    Now, I have two custom pages, listing the newly added products as well as the currently discounted products, using product blocks. These pages cache is not reset when a product is modified, which is how the plugin is designed to work. However, it would be nice to be able to reset these pages cache automatically. Of course, one solution would be to disable caching for these pages but that defeats the purpose of the plugin.

    Does anybody could share a snippet of code that would hook into the plugin logic that gets activated when a product is modified, and add the command to refresh a particular page? That way caching could be left enabled for that particular page, keeping its benefits, but getting cleaned up properly when, say, a new product is added to the site.

    • This topic was modified 1 year, 7 months ago by JackSim.
    • This topic was modified 1 year, 7 months ago by JackSim.
    • This topic was modified 1 year, 7 months ago by JackSim.
Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Support Tamirat B. (a11n)

    (@tamirat22)

    Hello @jacksim. Apologies for the late reply. We’re currently working on a backlog of support requests, and we generally answer in the order received.

    Thanks for surfacing this issue with our team. I was able to replicate the issue you reported on my test site.

    I have now raised the issue with our developers to check for any workarounds if there are any. We will follow up with you as soon as we have an update on this.

    Thanks for your patience!

    There’s no easy way to fix this but, meanwhile, setting the cache expiry time on your site to 5 minutes or less will mean those blocks update more quickly.

    Thread Starter JackSim

    (@jacksim)

    Thank you Donncha.

    However, on low traffic websites like ours, such a short expiry time would mean that basically every page load would need to be generated by WordPress and not come from the cache, so the cache would be basically useless. And almost every page load would take 1-2 seconds, failing the Web Vitals.

    I’m looking to cache pages for days, not minutes.

    BTW, I ran into a frustrating bug that clears the whole cache when I visit the admin area. I’m currently trying to narrow down the exact cirumstances that cause this. I will create another topic when I know more.

    If you can identify a filter or action used by those blocks when a product is altered and run the following command, with the URL of each page you want to clear the cache from:

    wpsc_delete_url_cache( 'https://example.com/products' );

    That will clear the cache for each page, so it updates next time someone visits.

    You could also fetch the page after clearing the cache, so the cache is already primed, or preloaded.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Refreshing custom pages when a product is modified’ is closed to new replies.