Computer Education
Tips Blog WinXP Internet Computing Downloads Vista/7 Home

Configuring the DNS Resolver Cache in Windows

To help speed up Web browsing, Windows XP, Vista, and 7 come with a local cache containing any DNS addresses that have been looked up recently. (For more detail on how Internet addresses work, see this article.) Once an URL has been resolved by an Internet name server into a numerical IP, the information is stored locally. Anytime your browser requests an URL, Windows first looks in the local cache to see if it is there before querying the external name server used by your ISP. If it finds the resolved URL locally it uses that IP. This is supposed to save time and cut down on Web traffic


Clear the DNS resolver cache

A problem can arise if the IP for an URL changes or the DNS entry gets corrupted while it is still stored in the local cache. In this case an error message will result if you try to connect to the URL. It is not a frequent occurrence but is not unknown. Fortunately, it is possible to clear out the local DNS cache in order to get around these types of problems. All current versions of Windows come with a useful command-line utility ipconfig (discussed here) that has a switch, flushdns, for removing the entries in the cache. Open a command prompt and enteripconfig /flushdnsand the cache will emptied. (In Windows Vista and Windows 7, it will be necessary to use the command line with elevated privileges.) Personally, I find that it sometimes speeds up Internet browsing to do this flush even when there are no obvious error messages.

If you are curious about the contents of the DNS cache, they can be seen by using another switch with ipconfig. In this case open a command prompt and enteripconfig /displaydns Also, if you are experiencing trouble connecting to a particular Web site, it may be useful to see if its URL is in the cache and what IP is being used.

Configure the DNS resolver cache in Windows XP

According to Microsoft, Windows XP keeps IPs in the DNS cache for a default time of 86,400 seconds or one day. (Various web browsers may actually use a shorter time.) This time period can be changed by reducing the Time to Live or TTL. This requires a Registry edit so should be done only by those who know how to restore their Registry. The Registry key that is involved is HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\DNSCache\Parameters The DWORD value MaxCacheTtl can be used to control how long positive responses are kept. This DWORD is normally missing and the default value is used. If you wish to change the TTL, create the entry and enter your preferred time in seconds. Most PC users will probably not gain much this way, however.

Negative responses are another story. There is a default DNS caching of negative results for fifteen minutes, which would be neither convenient nor necessary. I often encounter Web sites that do not respond immediately but which are available after a short wait and a retry. Although different browsers may use different parameters, I see no reason to store negative responses in the DNS cache and I have tweaked my own Registry to prevent them from being entered. In this case create a DWORD value for the above Registry key and name it MaxNegativeCacheTtl. Set the value to “0” (zero). If you prefer to keep the negative responses, but with a shorter TTL, enter the appropriate number of seconds. The default TTL is 900 seconds.

I have been unable to find any Microsoft reference about the cache times in Windows Vista and Windows 7 so the discussion in this section pertains to Windows XP only.

How to stop DNS caching

Normally, DNS caching is useful and speeds up web browsing. Should you wish to temporarily disable it for diagnostic purposes, there are two different command-line ways to achieve this. Open a command prompt (elevated privileges required in Windows Vista or 7) and enternet stop dnscache or enter sc stop dnscache


 << Home page ©2002-2014 Victor Laurie    Home page >>