Do you use a cookie that contains the country?
The crawler makes all pages cached in GBP.
The crawler doesn’t (and can’t) know that you use GeoIP.
Hi @sebastiaanvaz’ developer here.
We have the country code available through cloudflare’s proxy headers. we cannot rely on cookies, since they wont exist on first visit (and currency cookie will only exist if the user changes currency).
We currently use a Cache vary rule in the htaccess file:
<IfModule LiteSpeed>
RewriteEngine on
CacheLookup on
RewriteRule .* - [E="cache-vary:wcml_currency"]
</IfModule>
But this will only work if the cookie is present, if not the page will be cached (upon first visit of the page) based on the geo location of the user and the available currencies for that location. all other visitors will get to see this exact same page.
I believe that you have maneuvered yourselves into a dead end with the GeoIP detection. If I understood the initial description correctly, you want the user to be able to see the currency for their country based on the IP address. Without a page cache, using the GeoIP Database would be the right choice. But now it’s like that, and correct me if I’m wrong, that there is only 1 currency within the EU. It therefore makes little sense to assign a currency to the user based on their IP address if there is only 1 currency within the EU. This has far-reaching consequences when using cache varies, because then each country gets its own cache copy, regardless of the number of currencies offered. That makes 28 different cache varies for the EU alone. If you then also use the guest mode, webp replacement and mobile view, then 8 x 28 = 224 different cache varies (cache copies). Depending on the number of URLs, 228 cache copies become 228,000 URLs to be cached with 1000 URLs!
Basically what you want works. LiteSpeed provides everything with the GeoIP database and the cache varies, but you don’t get the cache managed, let alone that the cache can be warmed up for it.
I would strongly recommend a whole different approach if you want to listen to my suggestion?
Thank you for your response.
We serve countries worldwide. Besides, many countries in the EU have their own currency. Poland, Romania, Czech Republic, Sweden, etc… So we must offer the option of currency switching.
What would be your recommended approach then in this instance? We need to offer about 10 currencies in total.
We don’t make use of guest mode, as this caused currencies to be cached incorrectly (I could be wrong, though). But that’s what I thought to be witnessing.
The number of currencies actually has no relevance in relation to the URL-based page cache. The detection is IP-related and not currency-related. So I can only repeat myself. As long as you are looking for an IP-related solution, you will end up in a dead end, which is already foreseeable.
Also, WPML won’t be of much help to you. WPML is a PHP based solution, but when a URL is in the cache, the output is just more compressed plain text. That’s why there is no longer any PHP that could be used to detect an IP. Therefore it needs a server-based detection like the LiteSpeed GeoIP database, or the cache varies. But as already said, with the amount of countries (not the currencies) you don’t get the cache managed.
I would suggest you 1 or 2 solutions that are much easier to implement.
1.) Get rid of the idea of wanting automatic currency selection based on the IP address. I have sufficiently explained the reasons why.
2.) Use a plugin to select currency manually. However, this plugin has to work with cookies, so that a maximum of 10 cache varies can be created based on the cookie value. This is still a lot and will be even more if you want to use the previously mentioned cache plugin functions as well, but this will significantly reduce the number of cache varies. But you can’t warmup the cache with this solution either, because the built-in crawler doesn’t support your currencies. Only my cache crawler could do that.
3.) As an alternative to 2.) there would be a completely different solution using ESI (Edge Side Includes). With ESI, wholes can be punched into the website. An ESI whole is an area of content that has its own caching rules that are independent of the rest of a page. This would then also allow WPML to be used. In addition, you only need to vary 1 cache regardless of the number of currencies, so that the cache can be warmed up quickly. However, ESI also has a significant disadvantage and that is that ESI can kill performance. This can go so far that, despite the page cache, the advantage of loading time through the cache can be almost completely lost.
All in all, I can only warn you against pursuing the goal with IP detection.
Thanks for the suggestions, we are going to develop our own solution with the whole pricing done client-side and using some ajax requests, think this is closest to your suggestion number 3. This way we will only need 1 cached variant per page and allows us to still deliver speedy variable content based on the consumers location / preferences.
I didn’t know how extensive your programming skills are. Therefore, an AJAX solution is probably the better solution!
Thank you for your suggestions Cache crawler. We’d love to make use of your crawler though we use rankmath instead of Yoast. Any suggestions?
Maybe in the future. rankmath doesn’t have what our crawler needs to filter the posttypes. In the course of the year we will certainly make ourselves independent of YOAST. But I can’t give a timeline for that yet.
Plugin Support
qtwrk
(@qtwrk)
- Fragment the cache so that each currency is cached individually (doesn’t make sense to me because we have thousands of pages and almost 10 currencies, resulting in tens of thousands of cache variants)
well , sadly this is the solution , and probably the best available one , when you do 10 concurrencies , the cache size will be tenfold , one cache for EUR , one cache for GBP , one cache for USD , one cache for XXX currency and so on
@serpentdriver Mind putting us on an email list for this?
@qtwrk We now have changed the settings like this:
.nl domain = only EUR
.pl domain = only PLN
.eu domain = EUR default, possibility to change
Does this make any difference?