I would like to customize a landing page using IP based geo-location. I am pretty sure I know how to do this but I just wondering if it is the best design pattern or if there is a more elegant, efficient or refined way of doing things.
The website provides stats about events, when a user lands on a page I would like to populate the page with events close to the user's location. The user can then refine his/her search from there. This is really intended for a first interaction, example showing events on the homepage. Once the data is set, I will likely store it in a session cookie for future page views.
So the way I see this working is:
My server receive the users request for the page, I return a shell (page with static content) and collect the ip. I then take the ip, make an ajax call to a 3rd party geo/ip service that returns a json object with the geo-location data (coords, city, country etc...). Then, an ajax request is sent to my db with the geo-data that returns the result and populates the page.
The issue is that this seems like it my take some time, as I first have to wait for a third party and then I have to wait for my server to respond. Am I missing something.
Is this how it is typically done? Is there another way?