• Resolved xpod

    (@xpod)


    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 user’s country and map into the 3 groups with respective cache of the same URL.

    I’ve 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: [log in to see the link]

Viewing 13 replies - 1 through 13 (of 13 total)
  • Plugin Support qtwrk

    (@qtwrk)

    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,

    Thread Starter xpod

    (@xpod)

    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.

    Plugin Support qtwrk

    (@qtwrk)

    Hi,

    Well , since the CF sends that header , so crawler can’t 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,

    Thread Starter xpod

    (@xpod)

    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.

    Plugin Support qtwrk

    (@qtwrk)

    Hi,

    If the country detection is made by cookie, then it is possible to make crawler to pre-cache it.

    Best regards,

    Thread Starter xpod

    (@xpod)

    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?

    Plugin Support qtwrk

    (@qtwrk)

    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?

    Thread Starter xpod

    (@xpod)

    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?

    Thread Starter xpod

    (@xpod)

    @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.

    @qtwrk 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?

Viewing 13 replies - 1 through 13 (of 13 total)
  • The topic ‘Cache vary for different group of country with cloudflare Geo IP’ is closed to new replies.