Cart Liquid is cached when hit the back button

When I am at the HomePage, my cart is empty. So I add a product to cart and then i go to product page. when i hit the back button to back to Home Page, cart liquid now is empty. But when i reload, cart liquid has 1 item.

I use {{ cart.items }} to render items in cart.

This is loom: https://www.loom.com/share/0ce44a8530db44ecbf3c6a8bc3e1d9fd

Can you help me please?

I’ll make an assumption on what is happening based on what I saw in the video.

  • The sidebar is created with Liquid
  • Adding something to the cart doesn’t change the Liquid - it’s done post load
  • Moving to another page, and then back will load the browser cached version. Remember that it didn’t have anything in it to start with, and when adding it didn’t change the Liquid.

So really extra code should exist on the site to use JS to also check the current cart status. If there’s items in the cart, use JS to populate the sidebar just like it did when adding to the cart.

1 Like

Many thanks for your support. I will try to add JS script to check it.