Skip Navigation

This thread is resolved. Here is a description of the problem and solution.

Problem:
You are trying to cache translated posts but are unable to do so because of the _lsvary cookie, which affects caching behavior on your site.
Solution:
Currently, there is no update from the plugin authors regarding a solution to avoid the _lsvary cookie when caching translated posts. We previously reached out to the authors, and they are aware of the issue but have not provided a definitive solution yet.

We recommend contacting the plugin authors directly for the most recent updates on this issue.

The code below, provided by the client, eliminates the need to vary the cache based on currency. However, this approach is only suitable when a single currency is used per (sub)domain or URL. Please note that this code is untested and provided as-is, as it was not created by our team. We strongly recommend testing it thoroughly in a staging environment before implementation.

add_filter('litespeed_vary', 'unset_litespeed_wcml_vary_cookie', 99);
function unset_litespeed_wcml_vary_cookie($vary_list){
if (isset($vary_list['wcml_currency'])){
unset($vary_list['wcml_currency']);
}

return $vary_list;
}

If this solution does not apply to your case, or if it seems outdated, we highly recommend checking related known issues at https://wpml.org/known-issues/, verifying the version of the permanent fix, and confirming that you have installed the latest versions of themes and plugins. If you still need assistance, please open a new support ticket at our 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.

This topic contains 0 replies, has 2 voices.

Last updated by Marcel 5 days, 19 hours ago.

Assisted by: Marcel.

Author Posts
November 14, 2024 at 11:01 am #16401780

piaP-6

Background of the issue:
I am trying to cache the translated posts. It is not possible due to the _lsvary cookie. It happens at a product like this : hidden link

Symptoms:
I expected to get a LS cache hit after first visit. Instead i keep getting miss'es.

Questions:
How can I avoid the translated posts to have the _lsvary cookie? What WPML features is causing that?

November 14, 2024 at 11:52 am #16402326

piaP-6

Hi there,

I have found out that if I deactivate "Enable the multicurrency mode" in the WooCommerce Multilingual & Multicurrency with WPML plugin, the issue is not present.

However, that is of course not an option to deactivate that.

Best Regards,
Peter

November 18, 2024 at 1:56 pm #16415104

piaP-6

Hi there,

I hope you are able to check this ticket soon. I have found this old ticket with the same issue: https://wpml.org/forums/topic/follow-up-to-site-language-resetting-the-cache/ - are there any updates for a fix?

Best Regards,
Peter

November 18, 2024 at 5:39 pm #16416242

Marcel
Supporter

Languages: English (English ) German (Deutsch )

Timezone: Europe/Madrid (GMT+01:00)

Hi Peter,

Unfortunately, we don’t have an update on this. At the time, we reached out to the authors, and they informed us that they were "working on it but didn’t have a solid solution yet." That was the last information we received from them.

I would recommend contacting the authors directly for the latest updates.

Best regards,
Marcel

November 22, 2024 at 12:20 pm #16433732

piaP-6

The code below avoids the need for varying the cache based on currency. However, this is only suitable when only one currency is available on each (sub)domain/URL as it is in my case.

add_filter('litespeed_vary', 'unset_litespeed_wcml_vary_cookie', 99);
function unset_litespeed_wcml_vary_cookie($vary_list){
if (isset($vary_list['wcml_currency'])){
unset($vary_list['wcml_currency']);
}

return $vary_list;
}

November 22, 2024 at 2:59 pm #16434371

Marcel
Supporter

Languages: English (English ) German (Deutsch )

Timezone: Europe/Madrid (GMT+01:00)

Thank you for sharing! I'll add this to the ticket summary to make it easier for others to find and reference.

Best regards,
Marcel