networkaddress.cache.negative.ttl 的目的到底是什么?

What exactly is the purpose of networkaddress.cache.negative.ttl?

对于 class InetAddress,它有一个 属性“networkaddress.cache.negative.ttl”。 Javadoc 说

networkaddress.cache.negative.ttl (default: 10)

Specified in java.security to indicate the caching policy for un-successful name lookups from the name service.. The value is specified as integer to indicate the number of seconds to cache the failure for un-successful lookups.
A value of 0 indicates "never cache". A value of -1 indicates "cache forever".

请原谅我的愚蠢问题,如果名称查找不成功,有什么可以缓存?不成功的名称查找意味着没有 IP 地址 return 因此它不能缓存任何 IP 地址。

这是否意味着此参数只是简单地return“找不到主机”return-在缓存期间为同名查找编码,而不是执行实际的 DNS 查询?

谢谢

所有(递归)名称服务器都有负 TTL 的概念,即缓存“未找到数据”类型的答案的时间。

这是权威名称服务器在 SOA 字段中给出的,最后一项是负 TTL。如果域启用了 DNSSEC,它也可以从 NSEC/NSEC3 记录的 TTL 派生。

考虑到这一点,系统就不会过度查询已知不存在的内容。与所有缓存一样,它是一种性能优化,是本地内存(用于存储缓存)与网络 IO(用于发送和等待回复)之间的折衷。

例如,您可以在 https://serverfault.com/questions/426807/how-long-does-negative-dns-caching-typically-last 上的 DNS 级别找到更多详细信息。

Java框架似乎只是继承了这个思路,也有类似的设置。