This site requires JavaScript for navigation. Please enable JavaScript for the best learning experience.


As mentioned elsewhere in this tutorial, name servers and client resolvers store answers they get from other name servers. This information is added to their an internal database called the cache. Information about hosts is etained for a period of time equal to the time to live value sent by authoritative name server when it returned an answer about a particular host. The cache can contain both authoritative and non-authoritative information, depending on where the answer to the query for that particular host was provided from.

Storing these responses is called caching and allows a nameserver to respond more quickly to multiple queries for the same domain or host. If you are on a website, and want to retrieve the next page on the site, you click a link. Your web browser takes the name of the server, sends it to the the local name server to be turned into an IP address. Once your computer gets an answer, it does not have to look up the host again. Your local computer actually has its own DNS cache as well. Provided the time to live value hasn't expired, that answer will remain in the cache for some time. Once the time to live decays to zero the nameserver will delete the entries containing the host and address information. On your local computer, the cache is emptied when the local computer's default timeout is reached. This is an arbitrary value and is set to approximately 5 minutes on most Windows computers.

Caching is why it takes longer to contact a website on the first try but subsequent requests for pages on the same site are somewhat faster.

Negative Caching

The DNS application BIND version 4.9.3 and later supports negative caching as well (You'd better be on the latest version of BIND if you don't want to get hacked. --InetD). If the local server queries an authoritative server for information and receives an answer indicating that there is no such host, the local DNS server or resolver stores this answer as well, as there is no reason to look up this host twice if it does not exist. The host being down will not cause this response, but not having ANY record of it in the authoritative DNS server's database will cause this.

DNS Server Reloads

To flush the cache in BIND, you issue the following command:

# rndc flush

Why would you want to clear the name server cache file? Unfortunately caching is a two-edged sword. It speeds up resolution by storing recent answers, and short-circuiting the normal resolution process. However there is a down side. Because DNS servers cache answers, and don't delete these answers until the time to live expires, it can take hours, days or even weeks for the entire Internet to recognize changes to DNS information within your zone. In most cases, it is NOT possible to clear the nameserver's cache without shutting down the nameserver and restarting it. Since the server cannot resolve IPs or names while it is shut down, this effectively shuts down Internet communication for most users. This is usually not something a DNS administrator at a major ISP is willing to do without good cause. It is rare in the extreme to see major Tier 1 providers restart their DNS servers for any reason other than their own scheduled reload as this can prematurely reset version numbers, time to live and many other settings that will ripple through the Internet and cause other major headaches. If you ever find your job depends on getting them to restart their servers at anything other than their usual scheduled times, you'd better start looking for a new job. A restart of their servers means an outage for hundreds of thousands of companies and millions of users.

Clearing Your Resolver's Cache

The process differs depending upon which operating system you are using.


Windows provides the means to dump your local resolver cache. If you suspect your computer has stored a negative answer "host/domain not found" for some reason, then you can issue the following DOS command to clear your resolver's cache:

c:\ipconfig /flushdns

Mac OS & older BSD

Mac OS X and later uses 'lookupd'--a binary that provides diretory information and name caching functions. This function may require root privledges to run, which is dependent upon your local security configuration.

shell$ lookupd -flushcache


The client resolver is called 'nscd' (name service cache daemon). To wipe the cache, restart the daemon service with the following command:

/etc/rc.d/init.d/nscd restart


Some BSD systems don't come with resolver/caching software and simply use BIND. Be careful when issuing the flush command listed above.


Bookmark this page and SHARE:  


Support InetDaemon.Com

Get Tutorials in your INBOX!

Free Training