Typically, during the start of a new session, Sitecore uses an agent to asynchronously lookup the geo data of the visitor - but this means that geo-based personalization isn't available on the first page load. How do change this default Sitecore behavior to do the lookup before the first page load? What are the performance ramifications?
2 Answers
The geo lookup isn't fast enough to work for a first page. It's not even really worth trying.
If you must have it, you can hook into the GeoIP lookup service directly, or you can ajax in your content, to give the service a change to lookup the IP without destroying the user experience.
Some CDNs (like Akamai) can add headers to requests that will identify the geo location of the visitor - you can personalise on that more reliably than the ip lookup in most cases.
If you're looking to do language switching, consider using the Accept-Language
header instead. This tells you the language of the browser, which is better than assuming language based on location (if I travel to Japan I still view the web in English).
Of course you can also fall back to HTML5 geolocation and combine that with AJAX. It's probably more reliable than the GeoIP anyway.
Sitecore has a fix for this, but it has the drawback of possibly slowing your site down. With this KB you can specify the time in seconds you are willing to wait for the GeoIP lookup to get in sync with the fist page load.
-
Solution 2 on the page at the above link looks like it might also be viable. Commented Nov 4, 2016 at 4:54