What’s a DNS Cache?

Computer networking uses IP addresses to talk to a remote system. You may remember, but how about A DNS server exists to translate between the two values and make navigation easier.

Instead of requesting an IP address for a website every time, Windows 10 will build a cache mapping an IP address to a domain name as you browse the internet.

Reading the Windows 10 DNS Resolver Cache

Before you begin modifying your system by flushing the DNS cache, you should first know how to read it. You should always see what you’re removing before you remove it!

One way to read a local DNS cache is with PowerShell. PowerShell comes with a built-in cmdlet called Get-DnsClientCache that will return all entries in the cache.

  1. Open a PowerShell console by first using the key combination Windows Key+R to open the Run window.

Ensure you run PowerShell as administrator.

2. Enter powershell and press enter to open a Windows PowerShell session.

If you are using PowerShell 7.x, use pwsh at the Run prompt instead!

3. Run Get-DnsClientCache with no parameters as shown below. You’ll then see all of the DNS records that Windows 10 has cached.

Retrieving the contents of the DNS cache using the PowerShell command Get-DnsClientCache.
Retrieving the contents of the DNS cache using the PowerShell command Get-DnsClientCache.

4. If, for example, you only want to see specific types of records, use the Type parameter.

Get-DnsClientCache -Type A 
Returning only A records using the PowerShell command Get-DnsClientCache.
Returning only A records using the PowerShell command Get-DnsClientCache.

Using ipconfig /flushdns

The original way to flush DNS in Windows 10 (and earlier) is by using the ipconfig command. Although the ipconfig command has been around since Windows NT, it gained the ability to flush the DNS resolver cache in Windows 2000.

Use the ipconfig command to clear the Windows 10 DNS resolver cache by:

  1. Hit Windows Key+R to open up the Run window.

2. Type cmd to open up a command prompt window.

3. Type ipconfig /flushdns. The flushdns parameter finds the current resolver cache and removes all entries immediately.

 ipconfig /flushdns 
Flushing the Windows 10 DNS cache using ipconfig.
Flushing the Windows 10 DNS cache using ipconfig.

Related: The ipconfig Commands You Need to Know

Clearing the Windows 10 DNS Cache With PowerShell

Perhaps you’re writing an automation script and need to ensure the DNS resolver cache is cleared as part of it. Or maybe you just like PowerShell! Regardless, you can use a cmdlet called Clear-DnsClientCache to perform the exact same task as ipconfig.

To use PowerShell to clear the Windows 10 DNS resolve cache:

  1. While in PowerShell, run Clear-DnsClientCache and hit Enter.

You can also use the Verbose parameter to displays exactly what the command will do upon completion.

Clear-DnsClientCache # The Verbose parameter outputs user-friendly messages Clear-DnsClientCache -Verbose 
Clear the Windows 10 DNS Cache using PowerShell's Clear-DnsClientCache.
Clear the Windows 10 DNS Cache using PowerShell’s Clear-DnsClientCache.