gpt4 book ai didi

python - 避免在每个页面上运行 GeoIP

转载 作者:太空宇宙 更新时间:2023-11-03 19:09:24 25 4
gpt4 key购买 nike

这是我正在使用的模块:http://wiki.nginx.org/HttpGeoipModule

据我所知,由于它是在 nginx 配置和 uwsgi 上配置的,因此看起来别无选择,只能让它在每个页面上运行 geoip,然后仅在需要时收集和使用变量。

从性能的角度来看,我宁愿拥有它,所以我仅在需要时请求 geoip,将其缓存在 cookie 或 session 中,然后不再请求它以加快站点速度。

谁能告诉我这是否可行?

最佳答案

From a performance point of view I would rather have it so I request the geoip ONLY when needed, cache it in a cookie or session and then not request it again to speed up the site. Is anyone able to tell me if this is possible?`

是的,这是可能的。但从性能角度来看,您不必担心,因为 geoip 数据库存储在内存中(在读取配置阶段),并且 nginx 的查找速度非常快。

无论如何,如果你愿意,你可以使用类似的东西:

set $country $cookie_country;

if ($country == '') {
set $country $geoip_country_code;
add_header Set-Cookie country=$geoip_country_code;
}

uwsgi_param GEOIP_COUNTRY $country;

关于python - 避免在每个页面上运行 GeoIP,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13527848/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com