APO and Geolocation

Hello everybody,

We encountered some problems using APO with Geolocation plugins. Our setup is like this:

  • Wordpress with Geolocation IP Detection plugin, we are using some shortcodes approach to show/hide contact information depeding on visitor location
  • Geolocation IP detection plugin gets visitor information from CF headers
  • Kinsta hosting, they created individual, separate cache buckets for chosen countries (US, CA, AU, DE, GB)
  • Cloudflare, with Geolocation headers enabled

If we use the setup without APO or in developer mode, everything works as expected. But, I we enable the APO, purge the CF cache, then the first country that browses the cache, populates it worldwide, so if second visitor from another country browses the webpage, he sees the content meant for different country. Sometimes a mixed content, depends on time between browsing.

If a browser refresh or revisit is made, the right content is shown to this individual visitor.

I’ve tested and confirmed the problematic behaviour with Hoxx VPN, Tunnel Bear, Geotargetly.

To my very laic understanding, this is due to APO proactively pushing and replicating the content to CF datacenters (as opposed to pull), but the content is obviously ends up being same for all the countries.

Is this a bug or expected behavior, is this something that can and will be fixed or shall we stick to “Cache Everything”?

Thanks and best regards,
Andrej

How do you detect user IP? May be you detect wrong visitor IP.
If you detect valid visitor IP, then try to add a query string to that function and exclude cache for query string from cloudflare.

Thx for your thoughts. Geolocation IP Detection plugin has a predefined methods of identifying visitor P, one of them being Cloudflare’s headers.

image

My problem might or might not be related to this:

Well, after sometime to study about what you said and plugins, APO, it seem you are right.

May be APO cache all content to html on the edge so

This won’t work any more.
Hope someone at Cloudflare or other can have a solution for this. May be using rules + header request from origin server?

Hopefully someone from CF team will shed some light on that. Yevgen? :slight_smile: