1. Home
  2. Windows Tips
  3. Dns cache

What Is DNS Cache and How to Update It

The internet has evolved over the years in ways that aren’t apparent to the average user. Accessing a website may seem simple when we do it from inside our browsers but it’s a complicated, multi-step process. This process has been optimized so much that it seems to only take milliseconds for a website to load but behind the scenes, there’s a lot of components at work that make everything faster. One of these components is a DNS cache.

DNS is service that resolves a website name with the website’s IP address.

A website doesn’t actually have a user friendly name i.e., the URL, it has an IP address but users can’t remember IP addresses. They can remember URLs and the DNS is what is working behind the scenes to match a URL with its IP address.

DNS Cache

To help DNS work even faster, there is DNS cache. The name gives you a clue as to what it does. Essentially, the DNS cache keeps a record of websites you’ve visited. It knows that you’ve, for example, visited Wikipedia and it remembers what IP address it resolved to. The DNS cache helps the DNS not have to resolve frequently visited website addresses again, and again. When you type in an address, it’s first checked in the cache and if it’s there, it’s resolved through it. If the address isn’t found i.e., you’re visiting a website for the first time, the request will be sent to the DNS which will then resolve it.

The DNS cache is maintained by your OS but your browser also maintains a DNS cache. As browsers push to become faster, and to load content quicker, they incorporate tools to help them along. If, for example, you use Chrome and look up a website, Chrome will first check its own DNS cache. For Chrome it’s faster to use its own cache than it is to send a request to the OS to check in its own records. What this essentially means is that you have more than one DNS cache on your system. Normally this isn’t a problem unless of course something goes wrong and it’s hard to pinpoint where the problem is.

DNS Cache Problems

The DNS cache, particularly that of your browser, can be corrupted. There’s no single cause as to why this happens but it can be anything. If your cache hasn’t been refreshed in a long time, it too can lead to websites not loading.

There’s also a thing called DNS poisoning whereby malicious websites can insert or corrupt the records in the cache. This can lead to, for example, Facebook resolving to a malicious website that isn’t Facebook. If you’re a victim of DNS poisoning, you’re going to have to remove or block whatever is inserting IP addresses etc in it, and then clear the cache. If the cache is corrupted, or you’re having trouble resolving a website address, deleting the cache is what is going to fix it.

Delete DNS Cache

Chrome

To clear the DNS cache in Chrome, type the following in the address bar and click the ‘Clear host cache’ button.

chrome://net-internals/#dns

Firefox

Open Firefox and type in about:config in the address bar. Accept the on-screen warning to proceed to Firefox’s preferences. Here, search for the following preference and set its value to 0.

network.dnsCacheExpiration

Windows

To delete the Windows DNS cache, open a Command Prompt window with administrative rights. In the Command Prompt window, enter the following and tap Enter.

ipconfig /flushdns

macOS

To flush the DNS cache in macOS, you’re going to have to take into account what version of macOS you’re running. The commands are all run in Terminal so open the Terminal app, and run the command that applies to your version of macOS.

macOS Yosemite and later

 sudo killall -HUP mDNSResponder

macOS 10.10 –  10.10.3

sudo discoveryutil mdnsflushcache

You will have to enter your admin password in order to clear the cache.

iOS

To clear the DNS cache on your iPhone or iPad, turn on Airplane mode for 10-15 seconds. You can turn on Airplane mode from the Control Center or from the Settings app.

If this doesn’t resolve any problems you’re having, reboot your device and that will flush the DNS cache.

Android

You have to clear the DNS cache in Android through whichever browser it is you use. Open the Settings app and go to Apps. In the list of installed apps, tap the browser that you use. On the browser’s details page, you will see an entry for how much storage space it is using. Tap it. On the screen that shows you storage details, you will find a Clear Cache button. Tap it to clear the DNS cache.