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, 7 months ago.

Assisted by: Sumit.

Author Posts
January 27, 2023 at 7:32 pm #12906383

Sumit
Supporter

Languages: English (English )

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

Hi John,

Thanks for the feedback. Our cookie name is "wcml_client_currency" and we set it only when explicitly defined by the filter https://wpml.org/wcml-hook/wcml_user_store_strategy/ otherwise we use WC session to store the currency.

I am not sure why the cookie "wcml_currency" is being set. Are you using some kind of custom code/plugin?

Please let us know if htaccess code fixes the issue otherwise finding that cookie code and removing it should fix the issue.

Thanks

January 27, 2023 at 8:22 pm #12906565

John

Hey, I have just tested but it doesn't work.
Also please don't forget that all the tests are made on the default theme with wpml and LiteSpeed module active so we can exclude other incompatibilities.
Wouldn't be more easy to communicate with Litespeed dev directly so there won't be this kind of ping pong between us? Thanks 😀 and hope you understand.
All the best!

January 30, 2023 at 1:17 pm #12922031

Sumit
Supporter

Languages: English (English )

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

Hi John,

Yes, I understand but I was asking you to contact LiteSpeed as you are a customer and it will be more faster than us.

Anyway, I can see there is no resolution to your problem so I decided to debug this further in LiteSpeed plugin and found the problem.
After enabling the LiteSpeed logs I can see that cookie "wcml_currency" is being set but this cookie name does not exist in our entire plugin 🙂
After checking the LiteSpeed cache plugin code I found it is being set from LiteSpeed itself see here \plugins\litespeed-cache\thirdparty\wcml.cls.php

	public static function apply_client_currency( $currency ) {
		if ( $currency !== wcml_get_woocommerce_currency_option() ) {
			self::$_currency = $currency;
			add_filter( 'litespeed_vary', __CLASS__ . '::apply_vary' );
		}

		return $currency;
	}

	public static function apply_vary( $list ) {
		$list[ 'wcml_currency' ] = self::$_currency;
		return $list;
	}

As per this code, this seems to be expected behavior. They are setting a vary "wcml_currency" to create cache per currency meaning changing the currency or closing the browser will reset the cache.
If they have added this that means there was some currency issue with caching.

I am not sure what we can do here because if this is by design then only LiteSpeed can improve this.

I will ask our compatibility team to reach LiteSpeed regarding this question but if you wish you can also ping them and please ask them to send your query to the development team. This is not the support question anymore.

For, now I have made a minor change to bypass this class in the LiteSpeed plugin (same file) and the issue is fixed but not sure if there will be any problem regarding the currency.

I will update you as soon as we have any updates.

Thank you for your understanding.

January 30, 2023 at 1:23 pm #12922039

John

Sumit, what I can say more: You are the man here!
I appreciate how you decided to handle this issue, which I'm pretty sure other customers have experienced but maybe didn't observe.
As always I will forward your messages to them, and I hope they can also come up with a better solution.
Many thanks again and appreciate that you explain to us what is going on. 😀
Have an awesome week ahead! Keep in touch!

January 30, 2023 at 1:34 pm #12922135

Sumit
Supporter

Languages: English (English )

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

Thank you for the wonderful feedback! 🙂

I have already asked our team to contact them. I will keep you posted.

Have a nice week you too!

February 15, 2023 at 7:07 am #13035833

Sumit
Supporter

Languages: English (English )

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

Hi,

Our compatibility team contacted LiteSpeed and we got the response. As expected this is by design.

To make the Multicurrency work properly LiteSpeed uses a cookie per currency and creates a cached version of the page per currency when you close the private/incognito window the cookie is deleted and no cached page is served on the new request.

Furthermore, they said

while our developers are still exploring all possibility but we don't really have any solid solution right now 🙁

So you need to wait for the solution from them in future. Also, our developers suggested the same approach to use cookies to avoid problems with multicurrency. I am sorry but this is all we can do for now. However, I would give my personal opinion here that this should not create a huge impact on your site. Let me explain why, right now you are testing with a private window that always clears the cookie on closing the window. In real life, people usually do not use it. So when a normal user visits your site the first time they will see a non-cached version of the page (first slow response) and after that cached version (faster) will be served also if they revisit they will see the cache version as well.

I would suggest ignoring this problem for now as this is the most used approach by many cache plugins and recommended method by us as well.
Plugins vendors always work for improving things and I hope this will improve in the future.

Thank you!

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.