Wordpress LScache Plugin: Cache vary for different group of country with cloudflare Geo IP
Last Updated on: Wed, 15 Apr 2026 00:00:02 Hi all, I am testing on staging migration from nginx to OLS. One of the issue I have is my website need to show different currencies for 3 different group of country namely VN, AU and rest of the world. Under nginx, I have WP-Rocket and its extension Country Cache so plugin will identify users country and map into the 3 groups with respective cache of the same URL. Ive been trying to search Google but can not find a solution as I am just a seasoned wordpress user only. What I need is 1. if an user come from Vietnam, the cache for Vietnamese will be shown 2. if an user come from Australia, the cache for Aussie will be shown 3. if user does not fall into the above, show the international version. I am trying to use Cloudflare Geo IP that pass % cf-ipcountry . I was able to do this under nginx fast CGI in combination with WP-rocket but being stuck on Litespeed Any advice would be appreciated. The page I need help with: http://dev.chymeochy.com Hi, Please try use this rule into .htaccess and restart OLS RewriteEngine on 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] #if header shows AU , override it from other to au Best regards, Thank you very much, my initial testing seems to be working very well One more question, how would I adjust the crawler so LS Cache can produce the cache set for these 3 groups. Hi, Well , since the CF sends that header , so crawler cant do it , and I doubt that even you manually send it with curl command , CF will override it to the correct one it detect so as far as I see, there is no way you can do this from your origin server the only possible solution I can think of is to have multiple server across these 3 places , and then set up a custom crawler script to run on these remote servers in order to make CF send out correct country header. Best regards, thank you, let me look at the Country Cache for WP Rocket plugin and study a bit more since that plugin essentially create a cookie with country group. It may still work alone without WP Rocket. Hi, If the country detection is made by cookie, then it is possible to make crawler to pre-cache it. Best regards, Hi, just to be more detail, where in the .htaccess should I put those lines of code? Is this within the LSCache section or before/after that? Hi, I think it does not matter. Best regards, I am now on cloudflare, activated geo ip. Is that code above the only thing i have to add in the htaccess file? Or do i have to do something else? Yes, thats the only code needed. However it seems the LScache reset everytime a referal from Google or FB Ads. I have inconsistent cache display (mine was only about the currency) so I had to exclude cache for woo product pages Oh my god, it seems to work. Dont know what i did wrong yesterday. Now its testing time I disabled memcached before that thing of geolocation. Can i use memcached now too with this cloudflare and different cache for country? Thank you so much for your help and code! @xpod on cloudflare i have disabled caching . bypass my complete url because i have users that are logged in and of course they dont shall see cached content. When i am using litespeed cache (there is already set no caching for logged in users) like i do, is it correct that i have to disable cashing at cloudflare too or can i enable it anyway ? (Logged in users is a reason for my question and the geo ip rules) ? Do you know that? @xpod on cloudflare i have disabled caching . bypass my complete url because i have users that are logged in and of course they dont shall see cached content. When i am using litespeed cache (there is already set no caching for logged in users) like i do, is it correct that i have to disable cashing at cloudflare too or can i enable it anyway ? (Logged in users is a reason for my question and the geo ip rules) ? Do you know that? Hi, I use cloudflare full page cache for the front page only because Cloudflare free plan only cache 1 version of your site. My woo pages need dynamic pricing. For your site, you really need to determine the nature of logged-in and non-logged-in user to decide what kind of caching work best. @CacheCrawler I still have issues with LSCache as randomly the price for international user (should be in USD) got mixed up with e.g. Vietnamese currency (VND is the default woocommerce currency) and have to purge all caches. Do you think I can assign a cookie value to the cloudflare IP header so I can get the crawler to simulate?
LiteCache Rush: Speed comes from using less, not from doing it faster
Reference