I use Chromium and have problems with the DNS not being cached for the time that I would expect. Take the example.com domain. According to the DNS settings, this domain should be cached for another 26151 seconds:
$ dig example.com
;; ANSWER SECTION:
example.com. 26151 IN A 93.184.216.34
However, when I open example.com in Chromium and I open chrome://net-internals/#dns then the IP is forgotten within a minute!
Why does Chromium not adhere to the TTL of the DNS setting of the domain? How can I force it to cache the DNS data until they expire?
Best Answer
Chromium/Chrome does not cache DNS requests more than a minute indeed.
Interestingly enough, from bugs-chromium - Issue 164026 - DNS TTL not honored from Apr 21 2011
Answer in the Dec 4 2012 ticket:
Ticket closed on Oct 10 2013 as:
This has been a known issue for years; their internal DNS resolver ignores the TTL of DNS records, and only caches DNS requests for 1 minute.
Users have been requesting for years, a feature to change that default behavior, and Google never created one.
In the past, you could disable the internal DNS resolver in
chrome://flags
, nowadays that functionally is not exposed anymore.So summing it up, it is a feature, e.g. it does that by design.
(I initially wrote it could never be changed, which is not obviously not true. A really determined person can either recompile Chromium or hack Chrome binaries. ).
So, as an adenda: there is plenty of documented evidence Google engineers do not intend to respect the default TTL in received DNS answers in Chrome/ium.
From Negative Caching of DNS Queries (DNS NCACHE)
While it is implied a resolver may/should impose a maximum limit on caching DNS answer, the 1-min limit on Google Chrome may be too low.
P.S. I actually discovered the answer for something that has been bugging me for years while retrieving Chrome stats to answer this question: Chrome: DNS requests with random DNS names: malware?
PPS From the code bellow, it is apparent negative answers are not cached (TTL=0).
From https://chromium.googlesource.com/chromium/src/net/dns/host_resolver_impl.cc