texpert
texpert

Reputation: 162

Direct users to web page, based upon their city

Hii,

We want to redirect our users to one of our web pages corresponding to the users city (location based upon the users ip address and using some ip location databases)

My question is, how to make it work fast? for example in website gropoun, whenever the user visits, it instantly takes the user to its city page.

Thanks.

Edit: We are using PHP

Upvotes: 3

Views: 2502

Answers (4)

Will
Will

Reputation: 2162

I have done this for a few clients server-side using the lookup service http://ipinfodb.com/ip_location_api.php.

Just remember to store IP addresses and locations in the database so you do not do redundant lookups. I used the time zone data to determine the visitor's region.

Upvotes: 1

Kris Krause
Kris Krause

Reputation: 7326

Do you want to do this server or client side? If client side (ie, using javascript), you can use one of many geoip services out there. One in particular is Yahoo!'s YGL

Also, you can do it server-side using pretty much and language or framework. You could make API or service calls to third party geoip providers, or you can load the data into your database and do your own look up.

You will also need to "default" to a region or zipcode as every IP address can not be determined. For example, one web application that I currently work on has a 95% USA audience, so we default to the geographical center of the country which is 66952.

Upvotes: 2

Sean Vieira
Sean Vieira

Reputation: 160063

Cache, cache, cache everything. Cache lookups in your IP table, cache the results for individual users in their session or cookies, cache the rendered localization information portion of your pages (or at least the query intensive parts.)

There are more details that could be given, but it all depends on what your bottlenecks are. (After all there's no point in implementing complex caching on the routing side of things if the bottleneck is in rendering localized information because your DB calls take almost half a second to run). I cannot tell you where the bottlenecks in your application are / will be. You'll need to profile it first -- then optimize on the basis of what the profiler tells you.

Upvotes: 1

user12384512
user12384512

Reputation: 3401

You should determine user ip from httpRequest afterwards use some kind of database for example geoip

Upvotes: 1

Related Questions