根据用户所在城市将用户引导至网页

发布于 2024-09-24 12:08:08 字数 171 浏览 1 评论 0原文

您好,

我们希望将用户重定向到与用户所在城市相对应的网页之一(基于用户 IP 地址并使用一些 IP 位置数据库的位置)

我的问题是,如何使其快速运行?例如,在网站gropoun中,每当用户访问时,它都会立即将用户带到其城市页面。

谢谢。

编辑:我们正在使用 PHP

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

撩动你心 2024-10-01 12:08:09

缓存,缓存,缓存一切。在您的 IP 表中缓存查找,在会话或 cookie 中缓存单个用户的结果,缓存页面中呈现的本地化信息部分(或至少是查询密集部分)。

可以提供更多详细信息,但这一切取决于你的瓶颈是什么。 (毕竟,如果瓶颈在于呈现本地化信息,则在路由方面实现复杂的缓存是没有意义的,因为数据库调用需要几乎半秒的时间来运行)。我无法告诉您应用程序的瓶颈在/将在哪里。您需要首先对其进行分析——然后根据分析器告诉您的信息进行优化。

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.

婴鹅 2024-10-01 12:08:09

我已经使用查找服务 http://ipinfodb.com/ 在服务器端为一些客户端完成了此操作ip_location_api.php.

只需记住将 IP 地址和位置存储在数据库中,这样就不会进行冗余查找。我使用时区数据来确定访问者所在的区域。

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.

梦一生花开无言 2024-10-01 12:08:08

你想做这个服务器端还是客户端?如果是客户端(即使用 javascript),您可以使用众多 geoip 服务之一。其中特别值得一提的是 Yahoo! 的 YGL

另外,您可以使用几乎所有语言或框架在服务器端完成此操作。您可以向第三方 geoip 提供商进行 API 或服务调用,也可以将数据加载到数据库中并进行自己的查找。

您还需要“默认”某个区域或邮政编码,因为无法确定每个 IP 地址。例如,我目前开发的一个 Web 应用程序的受众群体中有 95% 是美国,因此我们默认该国家/地区的地理中心为 66952。

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.

月竹挽风 2024-10-01 12:08:08

您应该从 httpRequest 确定用户 ip,然后使用某种数据库,例如 geoip

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文