My last module work was on negative cache. While writing unit test for the module I gathered some knowledge about negative caching. Let us have a brief look into it!
DNS caching of unsuccessful name resolution attempts is called negative caching.
Let us understand it more elaborately. Resolver receives positive or negative responses to different queries. Accordingly it adds the respective response to its cache. The resolver always checks the cache before querying any DNS servers. If a name is in the cache, the resolver uses the name from the cache rather than querying a server. Since there is no resource record for an invalid name the server itself must decide how long to cache this negative information. Thus if a negative response is cached for a query it does not try to resolve it later rather sends the same response as a result of the query asked again.
Use of Negative Cache:
Negative caching is useful as it reduces the response time for negative answers. It also reduces the number of messages that have to be sent between resolvers and name servers hence overall network traffic. A large proportion of DNS traffic on the Internet could be eliminated if all resolvers implemented negative caching.
The ISPs which have multiple DNS servers take advantage of negative response and other response type cached to distinguish between different DNS servers. The failed DNS entry remains as long as the TTL is set. After TTL, DNS server is requeried because after this particular time limit the response entry will be dropped from the cache. But, the negative response still persists in the cache. That negative response prevents the machine from asking that particular DNS server, and instead it asks another server. This prevents a timeout error if that machine fails to respond. Even the negative response will be dropped later. Later DNS server which issued negative response may update itself by then.