Viewing 11 replies - 1 through 11 (of 11 total)
  • Plugin Contributor alexmigf

    (@alexmigf)

    Hello @julianoe

    There is no way around this unless you disabled server side caching altogether because when pages are cached, the dynamic parts will always need to be overwritten after the page has loaded (otherwise the customer would see a static/generic version of the page that knows nothing about their cart contents).

    If you could create some kind of exclusion for scripts that should help.

    Thread Starter julianoe

    (@julianoe)

    Thanks for the answer @alexmigf.

    There is no way to have a script running after the page loads that will go fetch again in the cookies (or localstorage) the cart information and update the front? Or do you mean that no script is running at all when server cache is active?

    Plugin Contributor alexmigf

    (@alexmigf)

    Hi @julianoe

    Can you share the site URL?

    Thread Starter julianoe

    (@julianoe)

    Here is the website we are working on: https://www.calyce-cidre.com

    Thread Starter julianoe

    (@julianoe)

    Just to be clear: when I load the page the cache often loads with the cart number being wrong but if I add a product to cart it is updated, the script runs as it should. Obviously when I switch page, it loads another cached page and the counter is wrong again.

    It is not good UX to have wrong numbers on page load for users. I’d rather hide the number with CSS for example and have a script that fetches the good number and then displays it again. Or something like that.

    Plugin Contributor Yordan Soares

    (@yordansoares)

    Hello @julianoe,

    I just tested your site and all appears to be working well:

    Plugin Contributor Yordan Soares

    (@yordansoares)

    Sorry @julianoe, I didn’t read your previous message.

    I just confirmed what you say: the item count display a wrong value when I navigate through other pages.

    You can hide the item count + the “article(s)” word adding this CSS rule to your Additional CSS area under Appearance > Customize:

    li.wpmenucartli a.wpmenucart-contents span {
        display: none !important;
    }

    But maybe my colleague @alexmigf could help you with a better approach for your case.

    Thread Starter julianoe

    (@julianoe)

    Thanks @yordansoares for taking time looking into this issue.
    The host uses Nginx server side cache. As recommended by Woocommerce I excluded the pages /cart /order and others from the caching to avoid big problems.

    My issue is not really how to hide it. I’d like to know if there is a way – maybe from previous experiences – that I missed by reading the other forum posts to avoid this or work around this problem.

    I tried adding just now a script from another issue that refreshes fragments but it does not fix it, even though the action run (I think), the number of products in the cart stays unchanged.

    Plugin Contributor alexmigf

    (@alexmigf)

    Hi @julianoe

    Seems to be working fine, did you change anything?

    Thread Starter julianoe

    (@julianoe)

    I had to disable the server cache. Clients seing the cart info from other clients is not possible.

    The issue is still going on : with nginx server cache enabled, even a script refreshing the woocommerce fragments does not seem to work and the menu cart does not display the right number.

    I’m surprised no one ever raised this issue as using server cache is a huge performance gain.

    Plugin Contributor Ewout

    (@pomegranate)

    @julianoe to rule out whether this is an issue with WooCommerce Menu Cart or your caching setup itself, can you try temporarily adding the WooCommerce Cart Widget (Appearence > Widget > Cart)to your site (somewhere in the footer if you need to test this on the live site) and check if that has the correct cart contents?

    Our plugin uses the core WooCommerce methods for replacing dynamic elements, but if the wc-ajax endpoint is cached, that will not allow any dynamic parts.

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘How should we handle server side cache?’ is closed to new replies.