• Resolved MagnusDux

    (@algirdasgricius)


    Hello,

    I was wondering if it is possible to cache for the countries that are INSIDE the European Union and OUTSIDE it.

    I need this because of the taxes and prices. All countries that are in the European Union have to see prices WITH VAT and every other country – WITHOUT VAT.

    I know that there is a variable called GEOIP_CITY_CONTINENT_CODE, but the problems is that some of the countries that are in Europe are not in the European Union.

    Is it maybe possible to do the caching by the GEOIP_CITY_CONTINENT_CODE, but also on top of that add a list of countries (one by one) that are not in the European Union.

Viewing 15 replies - 1 through 15 (of 21 total)
  • Thread Starter MagnusDux

    (@algirdasgricius)

    I have enabled the GeoIP on server side, everything is working but I don’t know how to write the htaccess rules to solve this problem.

    At the moment I’m using this:
    RewriteRule .* – [E=Cache-Control:vary=%{ENV:GEOIP_CITY_CONTINENT_CODE}]

    But, as I stated in my above post, this is not enough as there are some countries in Europe that are not in the European Union (Norway or UK , for example) and they should see a different cached version, without taxes.

    • This reply was modified 1 year, 3 months ago by MagnusDux.

    You must define all countries that are within EU and group them to 1 cache vary. Not tested, but the logic says that it should work.

    <IfModule mod_geoip.c>
    RewriteEngine on
    RewriteCond %{ENV:GEOIP_COUNTRY_CODE} ^(DE|FR|IT|AT)$
    RewriteRule .* - [E=Cache-Control:vary=%{ENV:LSCACHE_VARY_VALUE}+eu]
    </IfModule>
    Thread Starter MagnusDux

    (@algirdasgricius)

    I see, thank you!

    This rule only creates different cache copies depending on the yountry a user comes from, but not else. You need a PHP function as well that uses the same GEOIP database and this function displays price with or without tax depending on the yountry code. Both detection must be sync. Otherwise it will fail.

    But note that the detection is not safe. If someone is using a VPN service, you are likely to run into problems. That’s why I wouldn’t do it, I stick to what’s mandatory in your country.

    • This reply was modified 1 year, 3 months ago by litecache.
    Thread Starter MagnusDux

    (@algirdasgricius)

    Yes, I’m using Maxmind DB with WooCommerce and they are displaying the prices according to that so it should be ok.

    Thread Starter MagnusDux

    (@algirdasgricius)

    By the way, as I understand, the crawler will not know about this setup and will only crawl create one set of cached pages – the other will be generated from user visits, right?

    Yes, I’m using Maxmind DB with WooCommerce and they are displaying the prices according to that so it should be ok.

    Maxmind isn’t safe. If IP comes from VPN Maxmind will also fail.

    By the way, as I understand, the crawler will not know about this setup and will only crawl create one set of cached pages – the other will be generated from user visits, right?

    Right.

    Thread Starter MagnusDux

    (@algirdasgricius)

    Just to double check.

    RewriteCond %{ENV:GEOIP_COUNTRY_CODE} ^(DE|FR|IT|AT)$ RewriteRule .* – [E=Cache-Control:vary=%{ENV:LSCACHE_VARY_VALUE}+eu]

    This will make 1 cache for countries in the list and another, for all other countries, outside of the list. It’s not like DE, FR, IT, and AT will have separate caches, right?

    How about if someone comes from outside of the Europe, from the US or Asia, for example. How will the cache work then?

    How will the cache work then?

    There is no need to define extra cache vary for non EU visitors. Let’s say it’s the default cache vary. For these visiors you can use the crawler to warmup the cache.

    You seem to have made up your mind that you want to use GEOIP despite the unsafe use of it. But I have to tell you again, the disadvantages of using GEOIP clearly outweigh them and are therefore disproportionate. Above all, you cannot warm up the cache for EU users. There is a possibility that you could do it, but the necessary function in the cache plugin has not worked for a long time.

    However, I assume that you only want to use the GEOIP for tax purposes.

    Thread Starter MagnusDux

    (@algirdasgricius)

    I mean, what other choices do I have to speed up the delivery of the website, when I have different pricing for European Union countries and countries outside it?

    If you also have differentiated prices, then my criticism is put into perspective. But the problem with VPN remains. That’s why you have to take into account that someone can cheat cheaper prices.

    As already mentioned, there is a way for you to warm up the cache for all users, but since this feature doesn’t work in the cache plugin anymore, there’s little point in giving you details about it. Luckily there are other cache crawlers…..

    Thread Starter MagnusDux

    (@algirdasgricius)

    They can’t cheat the price, because it is being hard recalculated in the Checkout page, when the user enters the delivery address. This way the price will always be correct, so that’s not an issue.

    The only issue that remains then is how to warm up the cache for European Union users. You just mentioned that there are other cache crawlers. Can you explain what do you mean by that?

Viewing 15 replies - 1 through 15 (of 21 total)
  • The topic ‘Cache for European Union and outside it’ is closed to new replies.