I just want to add to this… the Cart Widget (on the header bar) seems to also be caching products from previous sessions. So if I hover over the Cart Widget, the cart products shown are different from the actual products in the cart. Clicking on the cart icon loads the actual cart products.
I found this post https://ww.wp.xz.cn/support/topic/mini-cart-is-cached-same-cart-contents-for-multiple-users/ and I added this to .htaccess
RewriteRule .* – [E=Cache-Vary:woocommerce_cart_hash]
It works in staging but not on the live site. Any ideas?
Plugin Support
qtwrk
(@qtwrk)
do you still have that cache-vary rule added ? please generate me the latest report again on live site.
Thank you for your reply. I think that I have fixed this issue now.
In addition to the rewrite rule, I needed to add “woocommerce_items_in_cart” to Litespeed > Cache > Excludes > Do Not Cache Cookies as per this tutorial https://chemicloud.com/kb/article/fix-litespeed-cache-woocommerce-conflicts/
I would recommend adding a tutorial to the Litespeed docs as the Mini Cart issue seems to be quite a common problem. I am using Woocommerce with Avada theme, and I expect that a lot of users have this combination.
It was also important for me to disable “Browser Cache” within Litespeed > Cache > Browser as this feature was caching the baskets of other users so the Mini Cart was displaying different products to the actual cart.
The problem with the Mini Cart disappearing has now started again, but only on 3 pages. Home, Skoda and Contact (I am using Avada Forms on the Contact page).
Here is the latest report number on the live site: ITTCDBAV
The staging site is working perfectly, with the rewrite rule only. I have not added “woocommerce_items_in_cart” to Do Not Cache Cookies on the staging site.
-
This reply was modified 2 years, 9 months ago by
simplecv.
-
This reply was modified 2 years, 9 months ago by
simplecv.
For anyone interested in Woo Mini Cart problems, this is how I have finally fixed the issue:
- Disable Quic Cloud CDN.
- Add “RewriteRule .* – [E=Cache-Vary:woocommerce_cart_hash]” to .htaccess
Notes:
- I am not a developer (experienced wordpress user maybe) but I can see that adding the code to .htaccess (rather than adding “woocommerce_items_in_cart” to Litespeed > Cache > Excludes > Do Not Cache Cookies means that the website and shop pages continue to be cached after a user has added products to the cart. This was really easy to test: Using the rewriterule, images were served as WebP after an item was added to the cart. Using the Cache > Excludes method images were served as JPegs after an item was added to the cart. I would be interest in a developer’s opinion (or Litespeed support) if anyone wants to comment regarding this…
- I assume my initial staging testing (see my third post here) regarding the fix working in staging but not live was because I had enabled the Quic Cloud CDN. It took me a while to work out that disabling this would fix the problem. Obviously I now have no CDN, but it’s better that my cart works properly.
- As mentioned higher up this thread, it was also important for me to disable “Browser Cache” within Litespeed > Cache > Browser as this feature was caching the baskets of other users so the Mini Cart was displaying different products to the actual cart.
Having used SG Optimizer and WP Rocket previously, I have to say that I found Litespeed Cache very frustrating. It seems like the Woo Mini Cart issus is quite common so I therefore hope that this post helps out other users. On the plus side, having migrated my website from Siteground, due to unacceptable reliability (down time) to Chemicloud (Litespeed Server), my website is now faster.
@simplecv Thank you very much for writing down your findings and solution. Your solution also worked for me, greatly appreciated sharing the fix.
For LiteSpeed Cache; I understand it’s very hard to write documentation that is one-size fits all, but I do believe there should be a place where these common issues are collected, explained, and list possible solutions.