Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cart quantity update issue (cache) #3122

Open
ludoboludo opened this issue Nov 22, 2023 · 2 comments
Open

Cart quantity update issue (cache) #3122

ludoboludo opened this issue Nov 22, 2023 · 2 comments

Comments

@ludoboludo
Copy link
Contributor

Describe the current behavior

the online store's cart page has a potential to be served from the browser's disk cache. If a buyer made changes to quantity, go to another page and click back button (to get back to cart), they would be seeing the old values for qty and total amount (although new values have taken).

Describe the expected behavior

When quantities are updated they should always be up to date.

Version information (Dawn, browsers and operating systems)

  • Dawn Version: 12.0.0
  • Chrome Version 108.0.5359.124
  • macOS Version 13.1

Possible solution

Additional context/screenshots

Here is some of the troubleshooting done by a colleague that brought up the issue to our attention:


Impact
Browsers: Chrome
(checked safari not a problem, did not check others)

Loading from bfcache (no problem)
Loading from disk cache (problem)
Reloading (no problem)

Why does going to guest checkout and back to cart, why is cart not serve from disk cache?
When checkout button is pressed, there is a request to /cart that has a 302 to the checkout. That /cart request invalidates the browser caching the cart page. So if the user were to come back to cart, say from the back button, the cart page isn't cached, and quantity totals show correctly.

Replication steps

Add product to cart
go to cart page
Change quantity
use back button
use forward button
You should see that the quantity and total is using the previous, if you hit reload the quantity and total is updated

@satish-bjss
Copy link

Is there any update on further fixes?

@naxorn
Copy link

naxorn commented Dec 5, 2023

Wasn't able to reproduce on Chrome with replication steps outlined, but was able to replicate bfcache issues still with Dawn (V12).

Steps to reproduce:

NOTE: You must test bfcache using the LIVE theme on a store. Previewing a theme doesn't work as bfcache loads a fresh page copy on back or forward... Didn't investigate, but guessing Shopify is sending no cache headers on previews, so Chrome disables bfcache.

Back issues

  1. Add product to cart
  2. Go to cart page
  3. Change quantity
  4. Click 'back' - cart totals show old totals on product page

Forward issues

Follow steps above then
5) Add product again - cart totals fixed now on product page
6) Click 'forward' - cart totals show old totals (and items if you decided to test that too)

bfcache testing code

<script>
  window.addEventListener('pageshow', (event) => {
    if (event.persisted) {
      // loading from bfcache (maybe disk cache too?)
      console.log('PAGE SHOW - persisted - ' + location.href);
    } else {
      console.log('PAGE SHOW - fresh - ' + location.href);
    }
  });
</script>

More details and fix suggestions on issue 2166

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants