What Is DNS Cache and How to Flush It

dns cache

We’ve covered the topic of what a DNS server is in the past and explained how they work. Basically, a DNS server is used to resolve a particular domain to its IP equivalent. However, this process takes time since once a new website request is made, the client must ask the resolver, which asks the root server, which asks the TLD server, for information. Needless to say, each additional check, adds extra time that the visitor must wait to receive a response.

Luckily, there is a mechanism in place to help reduce the frequency of which a website visitor’s browser must request a complete DNS lookup. This is called DNS cache. In this article, we’ll further explain what DNS cache is as well as outline how to flush your DNS cache.

What Is DNS Cache?

DNS cache refers to the temporary storage of information about previous DNS lookups on a machine’s OS or web browser. Keeping a local copy of a DNS lookup allows your OS or browser to quickly retrieve it and thus a website’s URL can be resolved to its corresponding IP much more efficiently. The basic function of different cache types is all more or less the same. However, if you need a more comprehensive explanation of cache, check out our cache definition article.

DNS caching does not only occur at the OS and browser level. In fact, as mentioned above, a DNS lookup involves various steps. During a new DNS lookup, the lookup passes through the resolver, root server, and TLD server. At each step, information is gathered and cached for later use. Therefore, even if the local DNS cache is empty, the resolver may have a cached copy of the required information thus, avoiding the need to go through the complete DNS lookup process.

Checking Your DNS Cache

You can check your operating system’s logs to see which DNS records are cached locally. The process for this will vary depending upon which operating system you use however, we’ve outlined how to achieve this on both Windows and Mac.

  • Window – The process for viewing your DNS cache entries in Windows is pretty simple. Simply open your command prompt and enter the following command: ipconfig /displaydns.
  • Mac – The process for viewing your DNS cache entries on a Mac is a little different. You’ll need to first open the Console app, select your device from the left sidebar and enter: any:mdnsresponder into the search bar. Next, open your command line and enter the following command: sudo killall -INFO mDNSResponder. You should then be able to go back to your console app and see the list of cached DNS records. For example, the screenshot below shows a cached CNAME record for edge.skype.com. cached dns entries

Additionally, you can also check your DNS cache entries on certain browsers. For example, if you’re using Chrome, you can enter: chrome://net-internals/#dns into your address bar which will return your browser’s current list of cached DNS records.

How To Flush DNS Cache

Depending upon your operating system or browser, the method used to flush your DNS cache will vary. As for why you would want to flush your DNS cache, this may vary as well. A couple of reasons include:

  • Troubleshooting connectivity issues
  • Troubleshooting and/or resolving DNS spoofing (e.g. DNS cache poisoning) issues
  • Resolving stale content issues (e.g. if a website has moved servers)

At the time of writing this article, we’ve gathered the latest operating system versions of both Mac and Windows and outlined the instructions below to clear your OS’s DNS cache.

  • Windows – Open your command prompt or click Run when you open your start menu. Then, enter the following command: ipconfig /flushdns. If the command succeeds, you will receive the following message “Successfully flushed the DNS Resolver Cache.”.
  • Mac – Open your command line interface or Terminal and enter the following command: sudo killall -HUP mDNSResponder. You may need to enter your administrator password. If the command succeeds the system will not return any output.

Additionally, to clear the DNS cache in Chrome browsers, navigate to chrome://net-internals/#dns and click the “Clear Host Cache” button.

Certain DNS servers such as Google’s Public DNS even allow you to flush the cache of a domain. Therefore, if you’ve recently changed DNS servers for your site and want to ensure that everyone who is using Google’s Public DNS will receive the latest version of your site you can use their flush cache tool.

google flush cache

Learn more about this tool in their FAQ section.

Summary

DNS cache is a very efficient way to avoid having to complete an entire DNS lookup each time you visit a site. Instead, this process will only need to occur the first time you visit the site and upon subsequent requests, your machine will use the OS’s and browser’s cached DNS information until it expires or is flushed.

If you need to flush or check your DNS cache for any one of the reasons mentioned above, simply follow the instructions that relate your specific OS.