[Resolved] Follow up to Site Language resetting the cache
This thread is resolved. Here is a description of the problem and solution.
Problem: The client is experiencing an issue where the site's cache resets every time a new
visitor enters the website when using WooCommerce Multilingual & Multicurrency with LiteSpeed Cache. LiteSpeed support
indicated that the issue is related to how WPML stores cookies.
Solution:
We discovered that the 'wcml_currency' cookie is being set by LiteSpeed itself, which is expected behavior to create a
cache per currency. Our compatibility team has reached out to LiteSpeed, and they confirmed that this is by design. They
are still exploring possible solutions, but there is no immediate fix.
We made a minor change to bypass the
problematic class in the LiteSpeed plugin, which fixed the issue, but it's uncertain if this will cause other problems
with currency handling. We will keep you updated on any developments.
In the meantime, we suggest ignoring
the problem for now, as it should not significantly impact your site. Most users do not frequently use private/incognito
windows, which clear cookies upon closing, so they will likely see cached pages on subsequent visits.
If this
solution does not apply to your case, or if it's outdated, we recommend opening a new support ticket. We also highly
recommend checking related known issues here, verifying
the version of the permanent fix, and confirming that you have installed the latest versions of themes and plugins. If
you need further assistance, please contact us in the WPML support forum.
This is the technical support forum for WPML - the multilingual WordPress plugin.
Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.
Also, I want to bring back some testing that we have done trying to solve the issue.
1. Fresh install of WordPress with WooCommerce, but still have the issue.
2. Trying with storefront theme, but still have the issue.
3. Trying with WooCommerce and wpml as actived plugins, still have the issue.
4. Trying without any functions and still having the issue.
So, the issue we have is with Site Language from WooCommerce Multilingual & Multicurrency and LiteSpeed. When we have set in WooCommerce Multilingual & Multicurrency Site Language and the caching will reset every time someone new enters the website.
If we deactived Site Language and move on Client Location the issue will dissapear, the generated cache will not reset at new client enters the website.
We need to use Site Language because sometimes will doesn't give the correct currency base on Client Location and we have tested using VPN.
Also, you cannot test the issue on the local host because you don't have LiteSpeed.
I also talked to those from LiteSpeed and they said that the problem is how the cookies are stored by WPML.
Please keep in mind, If we set to Client Location everything it's ok.
Can you please contact Litespeed support and ask them why and when ( in terms of code or in terms of some action or trigger on the site) is the cookie like the one below set on a site with Litespeed site? This info will help us further troubleshoot the issue.
Also, you said a fresh site with WordPress with WooCommerce install have the issue. Can you please setup a new clean test site with Litespeed setup WPML and WCML to recreate the issue and send me the access details of the site so that we can troubleshoot the issue further on that site?
I have enabled a private reply for you to share access credentials safely.
I am waiting for the updates with the Litespeed's answer to further escalate the issue to our team. Please let me know once you have an answer from the Litespeed team.
I'm Kor and I'll be assisting you here since my colleague is unavailable. I've checked the website you shared, and could you please record a short screen recording of how the issue can be replicated so that I can include this in the report I'm preparing?
I apologize for the delay, as I need to test on multiple PC to confirm the issue. However, when I tested on my Macbook using incognito Chrome mode, the cache from Litespeed worked fine.
Check out this recorded screen recording hidden link . Are you not getting the same?
Hello,
I have watched the video and it's working fine for you but, I have tested again from my pc, and the same issue.
Attached is a new video hidden link, maybe the difference between my video and yours it's the fact I purge all cache after saving the option.
Waiting for your reply,
Thank you!
I'm able to see the issue now on your Website. It looks like we've reached a point where we'll need further assistance from our 2nd Tier Support. I will write a report with all information I've gathered and share it with them. I will return to you once I've feedback.
As we concluded last time the issue is coming from LiteSpeed plugin. They are setting a cookie
_lscache_vary=ce8f2bf938969d9234120c518797e699 and this cookie is part of their cache key. As written here hidden link
When you close the window the cookie is cleared which means the cache key is changed and the cache is cleared.
Now when multicurrency is disabled the cookie is not set and it works correctly.
We asked this to check with Litespeed support and they said
"that cookie will be set upon first-time access (if the guest mode is enabled), or during login action (if guest mode is not enabled)"
I am not sure what is guest mode and why this cookie is being set. But the problem is this cookie. I have recorded a video showing this cookie is being set only when multicurrency is set. Please see here hidden link
Based on these observations I would suggest you following as workaround:-
1. Set this header via PHP or htaccess
X-litespeed-cache-control: no-vary
To disable this cookie as a cache key as per their docs. See how to set headers using htaccess hidden link
2. Turn off guest mode to avoid setting this cookie. (Based on last answer fro LiteSpeed)
Now the main question remains. Why this cookie is set only when multicurrency is enabled? As you know this can be answered by LiteSpeed support only. We can provide details of our plugins but we are not sure about their caching technique. It would be better if you can get a more detailed answer to this. If there is something that needs to be done from the WPML side we will check it for sure.
Hey Sumit,
Thank you for the very well-documented answers, I forward them to LiteSpeed support. As soon as I get an answer from them I will update the ticket.
Guest mode is a function on the Litespeed module but we are not using it so we can exclude that case.
Many thanks again and keep in touch.
I think the issue it gives miss because of this
[Vary] set_cookie ---> wcml_currency:EUR
it needs to set cookie for currency on the very first request , either to be EUR or USD or other currency , but when you opened it as in private window , this cookie is not set yet , so it misses the cache due to cookie not present.
RewriteCond %{HTTP_COOKIE} ! wcml_currency
RewriteRule ^ - [CO= wcml_currency:EUR:;]
add it at top of your .htaccess , see if it helps
Going to test with htaccess rules and let you know.
Thank you