Wordpress LScache Plugin: Assign value to cookie from Cloudflare Geo IP
Last Updated on: Wed, 15 Apr 2026 00:00:02 Hi, I have been having inconsistent with the caching of Litespeed. Mainly the issue is I have set the Woocommerce to display different currency to users from different currency using Cloudflare Geo IP header. I have used Cache vary as instructed but randomly the page would display wrong currency and it may likely due to bots. I am trying to use the crawler to simulate the roles of users from each country group to generate the correct version of cache. Is there anyway I can assign the value from Cloudflare Geo IP to cookie for use with cache vary and then use the crawler to simulate those cookies value? The page I need help with: http://chymeochy.com It is definitely possible, but you need to have enough resources to support multiple crawlers running. Please see the Cookie Simulation section of this blog post to see how its done. I only need 3 version of caches only for 3 currency. Im not sure how I can read the CF header and assign to cookie using .htaccess Hi, Could you please disable Cloudflare Cache first ? it will interfere a lot of things. Best regards, Hi, cloudflare cache is only for the homepage only. All other pages are not html cached with Cloudflare RewriteRule . - [E=Cache-Control:vary=other] #set default vary to other RewriteCond % HTTP:CF-IPCountry VN [NC] RewriteRule . - [E=Cache-Control:vary=vn] #if CF header for country shows VN , override it from other to vn RewriteCond % HTTP:CF-IPCountry AU [NC] RewriteRule . - [E=Cache-Control:vary=au] On this rewrite rules with Vary, the issue I have is many times when a bot (google) visit my site, it would come without Cloudflare Geo Header, and therefore will automatically be assigned with other and then since my default currency is VND , all my international customer will then see the cached version with VND . I am not familiar with the syntax of .htaccess so I can not figure out how to write the rule in the following logic: 1. Default vary value: VN ?> so that bot/crawler will always return the VN cache version, not overwriting other country version 2. If cloudflare header is VN ?> VN cache version 3. If cloudflare header is AU ?> AU cache version 4. If no cloudflare header or cloudflare header is not VN & AU ?> International version Hi, If you sure its google bot , then change RewriteCond % HTTP:CF-IPCountry VN [NC] RewriteRule . - [E=Cache-Control:vary=vn] to RewriteCond % HTTP:CF-IPCountry VN [NC,OR] RewriteCond % HTTP_USER_AGENT Googlebot [NC] RewriteRule . - [E=Cache-Control:vary=vn] then if incoming reqeust have cf header with VN , or UA shows google bot , will have vary for VN. Best regards, I am not too sure actually, its my only logical explanation because the cache was rendered for the wrong group of country many times (displaying default store currency instead). My only possible thinking now is some visit without a Cloudflare header which should be Search engine bot or the crawler (which I have turned off but issue still persists) Found this in the OLS server log and I think its the reason for wrong cache [162.158.158.205:26624#chymeochy.com] [Module:Cache] vary request header Origin not defined! Do you think there is a way to get the above case to render under VN value Hi, No , this log wont affect vary. I am visiting from Spain , what currency should I see ? Best regards, Spain should see USD My rule is for Vietnamese, it shows Woo default currency VND For Australian, it shows AUD and the rest of the world shows USD When I use geopeeker.com to check my website from different location, many times I got it displayed in VND instead of USD AUD is always rendered correctly. Then I have to purge the cache so it got to displayed correctly again. The easiest way to check is visit: chymeochy.com/sale/ RewriteEngine on RewriteRule . - [E=Cache-Control:vary=other] #set default vary to other RewriteCond % HTTP:CF-IPCountry VN [NC,OR] RewriteCond % HTTP_USER_AGENT Googlebot [NC] RewriteRule . - [E=Cache-Control:vary=vn] #if CF header for country shows VN , override it from other to vn RewriteCond % HTTP:CF-IPCountry AU [NC] RewriteRule . - [E=Cache-Control:vary=au] #if header shows AU , override it from other to au RewriteCond % HTTP:CF-IPCountry US|CA|SG|MY [NC] RewriteRule . - [E=Cache-Control:vary=int] #if header shows US CA SG MY , override it from other to int @CacheCrawler I added US CA SG MY to the list of separate cache to make sure user from these country got displayed correctly. Can you please check if the code I wrote is correct as I am not familiar with the syntax of .htaccess file. Under this, I still randomly got wrong currency for US customers and not sure why Hi, From the rule , I dont see any imminent error. You may need to enable server debug log , to see what exactly was going on when request coming in , and how it was interprete with rewriterule. Without rewrite rule log , it would be hard if not impossible to figure out why it didnt vary correctly. Best regards, @CacheCrawler can you please be specific as to how to enable it. Under my OLS admin interface, Log level was set to Debug and Debug level set to None.
LiteCache Rush: Speed comes from using less, not from doing it faster
Reference