Setup to get city by IP number with Geokit

195 views Asked by At

I have a Rails 4 app deployed on Heroku.

I have a method that decode an ip number to it´s city equivalent.

From what I've understood there are a bunch of pitfalls when geocoding, i.e. reaching request limit on shared ip, unupdated geocode providers etc.

If someone has any recent experience of any similar user case as the one described above, it would be much appreciated to learn what setup works (if at all) best.

1

There are 1 answers

0
Michael Noack On

Two key things you can do easily and should be more than sufficient are:

  1. Use geokit's MultiGeocoder and ip_provider_order to define which geocoders to fall back on when a failure occurs.

  2. Cache results. There's currently a pull request in geokit that adds an inbuilt caching option but writing your own cache is easy plus you could make it smarter. E.g. if an IP is similar to another IP e.g first three parts are same it's probably the same location.

Harder options might be to have the entire ip database in your app thus not needing to make any requests at all.