Skip Navigation

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.

Tagged: 

This topic contains 20 replies, has 4 voices.

Last updated by Sumit 1 year, 9 months ago.

Assisted by: Sumit.

Author Posts
December 12, 2022 at 1:48 pm #12635511

John

Hello,

I have a ticket on you regarding Site Language resetting the cache but I didn't manage to come back to you and now the ticket it's closed. https://wpml.org/forums/topic/wpml-client-location-reset-caching/

We didn't manage the solve the issue.

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.

Waiting for your reply,

Thank you!

December 14, 2022 at 10:24 am #12648349

Subash Chandra Poudel

Hi there,

Thank you for getting back with the updates.

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.

set-cookie: _lscache_vary=ce8f2bf938969d9234120c518797e699; expires=Sun, 27-Nov-2022 15:38:52 GMT; Max-Age=172800; path=/; secure; HttpOnly

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.

Regards,
Subash

December 15, 2022 at 9:21 am #12655705

Subash Chandra Poudel

Hi there,

Thank you for the details.

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.

Regards,
Subash

December 20, 2022 at 6:49 pm #12686685

John

I got the following message from LiteSpeed support

"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)"

Maybe you can contact them directly on slack, thanks.
hidden link

December 22, 2022 at 7:09 pm #12703049

Kor
Supporter

Languages: English (English )

Timezone: Asia/Singapore (GMT+08:00)

Hi there,

Thanks for your reply.

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?

Thanks!

Kor

December 23, 2022 at 10:10 am #12705615

John

I might have left the video link in the previous topic, maybe you can check the past threat so you can understand better our issue. hidden link
Thanks

December 26, 2022 at 7:59 pm #12714953

Kor
Supporter

Languages: English (English )

Timezone: Asia/Singapore (GMT+08:00)

Hi there,

Thanks for your reply.

I'll look into this and I will come back to you as quickly as possible.

Thanks!

Kor

December 28, 2022 at 8:10 am #12721225

Kor
Supporter

Languages: English (English )

Timezone: Asia/Singapore (GMT+08:00)

Hi there,

Thanks for your patience.

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?

Thanks!

Kor

January 4, 2023 at 1:19 pm #12751195

John

Hello,
Thank you for your answer. Please let the ticket open until Tuesday and we are come back to you with an answer.
Thank you!

January 4, 2023 at 4:32 pm #12753233

Kor
Supporter

Languages: English (English )

Timezone: Asia/Singapore (GMT+08:00)

Hi there,

Thanks for your reply.

Sure thing.

Thanks!

Kor

January 9, 2023 at 4:20 pm #12778949

John

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!

January 11, 2023 at 6:11 pm #12798105

Kor
Supporter

Languages: English (English )

Timezone: Asia/Singapore (GMT+08:00)

Hi there,

Thanks for your reply.

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.

Thanks!

Kor

January 17, 2023 at 1:45 pm #12834707

Sumit
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hi,

I am Sumit from 2nd tier support.

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.

I hope it helps.

Thanks

January 17, 2023 at 2:11 pm #12834849

John

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.

January 25, 2023 at 11:10 am #12888979

John

Hello, I got the following response from support.

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