• Resolved arithdevlpr

    (@arithdevlpr)


    I am trying really hard to figure out how to be able to cache my product pages but still have a “add to quote” button generated by a separate plugin to work. I do not have ESI enabled.

    When the page is cached, the default add to cart works fine but not this third party plugin. It just reloads the page without doing anything and then when i revisit or trigger the proper add to cart it serves the fresh page. The issue is similar to the one posted here: https://www.ads-software.com/support/topic/add-to-cart-is-reloading-the-page/ but from his solution on adding exclusions i’m not entirely sure if i’m adding the full urls to the right section under Tuning settings for both CSS and JS.

    Report number:?PFTHAORA

    The page I need help with: [log in to see the link]

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

    (@qtwrk)

    I just tried add to cart and to quote , seems okay on me

    did you see any 403 error in dev tool when that happens ? I feel might be nonce issue

    Thread Starter arithdevlpr

    (@arithdevlpr)

    oh yes sorry i disabled cache for ^/product/ pages so it works but ideally i want to enable cache to further speed things since i have about 2000 product pages.

    I’ve just enabled it now so if you refresh and try again you’ll see what i mean

    Plugin Support qtwrk

    (@qtwrk)

    this is what it shows on me after clicked add to cart, what should it be ?

    Thread Starter arithdevlpr

    (@arithdevlpr)

    Try and add to quote. For reference on this product page i’ve force disabled cache so you can see the functionality. :https://rifftsafety.co.nz/product/10l-diesel-jerry-can/

    The thing is the add to cart button is woocommerce direct but the add to quote is generated by another plugin – B2B by Addify.

    As per the other thread the guy’s workaround was to:

    Normally without any optimization Add to cart is done using AJAX without reloading. But with Litespeed optimization, it reloads the page.

    So I just needed the names of the files responsible for this Add to cart functionality.

    Anyway, I figured it out.

    Excluded add-to-cart.css and my cart plugin CSS files from all optimization. It’s working now!

    but i’m not entirely sure how or where to try and add this exclusion as it relates to the specific plugin I am using

    Plugin Support qtwrk

    (@qtwrk)

    this is what it shows after add quote

    I don’t see how a CSS will related to page reloads or not , does it also reload previously when you have it excluded from cache ?

    what he mentions is probably in Page Optm -> Tuning CSS -> CSS exclude though , you can give it a try

    Thread Starter arithdevlpr

    (@arithdevlpr)

    Yes if the product page is set to Do Not Cache, the add to quote will work just fine. but if i do cache the product pages, the add to quote breaks.

    Were you able to also try add to quote for the https://rifftsafety.co.nz/product/hiviz-x-back-vest-transit-orange/ page which is cached?

    There are other threads on the subject around too but it seems to be a case by case and in my case even after adding the full url to the css files/folders i want to exclude it still doesnt seem to be working when the page is cached.

    Is there a way to tell if an element/css/js file has been properly excluded from being cached?

    Plugin Support qtwrk

    (@qtwrk)

    js/css are never cached, they are only minified or combined


    function lscwp_custom_purge_on_add_cart() {
    if ($_SERVER['REQUEST_METHOD'] === 'POST' && defined('LSCWP_V')) {
    if (isset($_POST['action']) && $_POST['action'] === 'add_to_quote_single_vari' &&
    isset($_POST['product_id'])
    ) {
    do_action( 'litespeed_purge_post', $_POST['product_id'] );
    }
    }
    }
    add_action('init', 'lscwp_custom_purge_on_add_cart');

    function buffer_output_before($content) {
    if (strpos($content, 'Products in your quote enquiry basket') !== false) {
    @header('X-LiteSpeed-Cache-Control: no-cache');
    }
    return $content;
    }

    add_filter('litespeed_buffer_before', 'buffer_output_before', 0);

    please try this code snippet

    Thread Starter arithdevlpr

    (@arithdevlpr)

    In my CSS and JS excludes i have

    /wp-content/plugins/b2b/woocommerce-request-a-quote/assets/css/(.*).css

    /wp-content/plugins/b2b/woocommerce-request-a-quote/assets/js/(.*).js

    I’ve added the snippet you provided, cleared all cache, and oh wow it works now after a small few seconds of delay. Thank you!. just out of curiousity what do you think was the issue?

    Plugin Support qtwrk

    (@qtwrk)

    (.*) this won’t work

    put /wp-content/plugins/b2b/woocommerce-request-a-quote/assets/js/ and /wp-content/plugins/b2b/woocommerce-request-a-quote/assets/css for partial match that matches everything within these 2 dir

    because the page was cached already , so it doesn’t pop up new content , ideally this should be handled by theme or something with ajax call , which is optimal , what I did is to purge the page when quote is added , so it displays new content , not exactly the best solution , but I guess it has to be

    Thread Starter arithdevlpr

    (@arithdevlpr)

    I see. thanks for that. it’s working now and you have given me a good starting point to look into further optimisation with the ajax call in the future if it’s really necessary. Thanks a bunch!

    Thread Starter arithdevlpr

    (@arithdevlpr)

    sorry, just a followup question, since your workaround is purging the page’s cache whenever the add to quote button is pressed, does that mean it will need to be recrawled everytime?

    Plugin Support qtwrk

    (@qtwrk)

    please explain a bit what do you mean by “recrawled” in this context

    Thread Starter arithdevlpr

    (@arithdevlpr)

    I’m sorry, I am brand new learning about these caching concepts.

    So I have Quic cloud setup and the litespeed crawler running on a cron job once every night.

    From my understanding, when the page’s cache is purged, it may take a while for it to be re-cached and for the server to serve a cached page to a new visitor right? so meaning in this case i must wait until the crawler does its thing to re-cache the page?

    Plugin Support qtwrk

    (@qtwrk)

    yes, page will be cached again after crawler hits or other visitor hits it

    that’s why I said ajax call is optimal solution since it doesn’t purge cache

    Thread Starter arithdevlpr

    (@arithdevlpr)

    I see, so the ideal situation is to request the developer to use an ajax call for the button instead of javascript trigger?

    I wonder if there is another workaround to trigger the crawler to run for that specific page immediately after the cache was purged.

Viewing 15 replies - 1 through 15 (of 22 total)
  • You must be logged in to reply to this topic.