Nginx 默认 dns 解析缓存有效期是多少呢?

2022-11-30 10:38:50 +08:00
 fighterhit
看文档上面没说,代码里面没找到有常量定义,有大佬了解吗?
http://nginx.org/en/docs/http/ngx_http_core_module.html#resolver
608 次点击
所在节点    问与答
6 条回复
XIU2
2022-11-30 10:43:04 +08:00
我记得是 Nginx 启动时会对域名进行 DNS 解析,然后就一直使用得到的 IP 地址,直到重载或重启 Nginx 。
blackeeper
2022-11-30 11:02:05 +08:00
官方不是有么 [valid=time],可以自定义
Syntax: resolver address ... [valid=time] [ipv4=on|off] [ipv6=on|off] [status_zone=zone];
Default: —
Context: http, server, location
fighterhit
2022-12-01 23:36:30 +08:00
@blackeeper 嗯,想知道没定义的情况下默认是多少
fighterhit
2022-12-01 23:37:13 +08:00
@XIU2 嗯,发现后端 k8s service 没了,nginx dns 解析 service name 还是到老的 clusterIP
blackeeper
2022-12-02 09:58:21 +08:00
官方文档,默认就是 TTL 值,1.1.9 之前的版本 5 分钟

By default, nginx caches answers using the TTL value of a response. An optional valid parameter allows overriding it:

resolver 127.0.0.1 [::1]:5353 valid=30s;
Before version 1.1.9, tuning of caching time was not possible, and nginx always cached answers for the duration of 5 minutes.
@fighterhit
fighterhit
2022-12-03 21:38:05 +08:00
@blackeeper 嗯这个看到过,1.1.9 太早了,现在默认多少呢

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/898998

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX