DNS cache is a temporary database that is basically managed by your operating system. This database contains listings for all domains previously visited.
How DNS cache works
A URL (a domain) can be described as an alias for an IP address. Like names in your phonebook are aliases for phone numbers.
When you enter a url in the browser, the query is first sent to your operating system’s local DNS cache, to try to find a result. That is, an IP address that corresponds to the query on the domain.
If no local result is found, the request is forwarded to your router, which has set up a primary DNS server to which it forwards the request.
There are lots of public DNS servers where the domain can be queried and the query will be forwarded in the system until the domain’s primary name server is found. When and if the router receives a valid response, it will understand what to send back to your browser.
If you are using Windows, you can see what your DNS cache contains by opening the command prompt and typing
ipconfig /displaydns. Then you will get an answer formatted like this:
DNS cache can be a huge help for most people, as it is always faster to make a local lookup, rather than having to send queries to the router and make lookups to public DNS servers every time you visit a website.
Do you work with websites and have problems with DNS cache?
If you, like me, work with websites, there may occasionally be problems with DNS cache. Problems occur in most cases when a website is moved from one server (IP address) to another. For example. when switching to a new agency/supplier.
Here, DNS cache can be a bigger problem than you might want, but fortunately there is often a quick solution.
If you are using Windows, you can go to the command prompt and type
ipconfig /flushdns. It will clear your local DNS cache, and in many cases also be enough. On Mac, one will similarly use
dscacheutil -flushcache, and on Linux
/etc/rc.d/init.d/nscd restart. Note that usually only Windows will give a message similar to “Successfully flushed the DNS Resolver Cache.”.
If you’re still having issues, try clearing Google’s public DNS cache at https://developers.google.com/speed/public-dns/cache. Here you need to clear the cache for each domain, subdomain and for each record type. Usually, it will be enough to clear the A record for “domain.com” and “www.domain.com”.
Is the DNS cache still causing problems?
In some cases, your router may also have a built-in DNS cache. This is usually cleared within 24 hours. Although it can be frustrating for both the website owner and any supplier, there is unfortunately no easy fix that works for everyone.
If you as a vendor / developer are a bit nerdy, you can edit your hosts file (on Windows). Of course, it will only work locally for you, but it will allow you to check that the website works at the new IP address.
Your hosts file can be found at C:\Windows\System32\drivers\etc and should be opened in any text editor. In this file, each line represents a new lookup, and will be used as the primary lookup above all else.
To test the new configuration, insert a new line of IP address, space and domain name. For example.:
And usually you will also write www version too – still on a new line:
Once you have entered the new settings, simply save and test the domain in your favorite browser.
What is your experience with DNS cache? Feel free to share your experiences and thoughts in the comments :)