@
AkinoKaedeChan 是这么个道理,但是我觉得这还是一个很好的 trade off 。就算上游 dns 在乐观缓存被 invalidate 前上游权威正好更新了,也是牺牲极小概率的出口 mismatch 换每几分钟一次,可能上百毫秒的 dns 请求延迟。
查了下 RFC ,可能你说的是这句话?
"Answers from authoritative servers that have a DNS response code of either 0 (NoError) or 3 (NXDomain) and the Authoritative Answer (AA) bit set MUST be considered to have refreshed the data at the resolver. Answers from authoritative servers that have any other response code SHOULD be considered a failure to refresh the data and therefore leave any previous state intact. "
也就是对于一个 dns server ,如果上游没有 error ,那必须要在返回结果前已经更新了自己的 DNS cache ,如果没更新就返回之前的结果,视为操作错误。这么理解的话严格上确实不能乐观缓存。