What Is DNS Cache
DNS cache is a temporary storage layer that saves the results of DNS lookups so future requests for the same domain resolve faster. Every time you type a domain name like example.com, your device must translate it into an IP address like 93.184.216.34. This translation process involves multiple steps: checking local caches, querying recursive resolvers, and communicating with authoritative nameservers. DNS cache eliminates redundant work by remembering the answer.
Think of DNS cache like a phone contact list. The first time you look up a friend's number, you search the directory. Once you find it, you save it in your contacts. The next time you need that number, you check your contacts instead of searching the entire directory again. DNS cache works identically — it stores previously resolved domain-to-IP mappings so your device can skip the full resolution process.
DNS caching exists at three levels: the browser, the operating system, and the DNS resolver. Each level has its own cache with separate expiry rules. When you visit a site, your browser checks its own cache first. If the entry is missing or expired, the operating system cache is consulted. Only if both are empty does a real DNS query leave your device. This layered approach means most DNS lookups are resolved locally, dramatically reducing latency.
The importance of DNS cache extends beyond speed. It reduces load on DNS infrastructure, minimizes bandwidth usage, and provides a measure of resilience — if a DNS server becomes temporarily unreachable, cached entries allow your device to continue resolving known domains. However, caching also introduces staleness: if a domain's IP address changes, outdated cache entries can temporarily route you to the wrong server until the cache expires.
How DNS Caching Works
DNS caching follows a hierarchical lookup sequence. When you request a domain, your system checks multiple cache layers in order:
1. Browser Cache: Your browser maintains its own DNS cache, typically the fastest to query. Chrome, Firefox, and Safari each store resolved records internally. Chrome's cache can be viewed at chrome://net-internals/#dns. If the browser has a valid (non-expired) record, it returns the IP immediately without consulting the OS.
2. OS Cache: If the browser cache misses, the operating system checks its DNS cache. On Windows, this is managed by the DNS Client service (Dnscache). On macOS, it is managed by mDNSResponder. On Linux, systemd-resolved or nscd handles caching. The OS cache covers all applications, not just the browser.
3. Stub Resolver: If the OS cache is empty, the stub resolver forwards the query to the configured recursive resolver (usually provided by your ISP or a public DNS service like 1.1.1.1 or 8.8.8.8). The recursive resolver checks its own cache first — this is the largest and most shared cache in the chain.
4. Recursive Resolution: If the recursive resolver's cache also misses, it performs full recursive resolution: querying root servers, TLD servers (.com, .org, etc.), and authoritative nameservers. The result is then cached at every level on its way back to your device.
5. Negative Caching: DNS also caches failures. If a domain does not exist (NXDOMAIN), that negative result is cached for a period defined by the SOA record's minimum TTL. This prevents repeated queries for typos or non-existent domains.
Each cached record has a TTL counter that decrements in real time. When TTL reaches zero, the record is considered stale and removed from cache. The next lookup for that domain triggers a fresh resolution cycle.
TTL Explained
TTL (Time To Live) is a numerical value, measured in seconds, that tells DNS resolvers how long to keep a cached record before discarding it. It is set by the domain owner in their DNS zone file and is included in every DNS response. Common TTL values range from 300 seconds (5 minutes) to 86400 seconds (24 hours).
A low TTL (300–600 seconds) means records expire quickly, so DNS changes propagate faster. Domain owners typically lower their TTL before making planned DNS changes — for example, migrating to a new hosting provider. After the migration is complete, they raise the TTL back to normal levels to reduce query load.
A high TTL (3600–86400 seconds) means records stay cached longer, reducing DNS query traffic and improving resolution speed. However, it also means that if the domain's IP address changes, users may be routed to the old IP until the cache expires. This is why very high TTLs can cause connectivity issues after DNS changes.
TTL values are hierarchical. The authoritative nameserver sets the TTL, but recursive resolvers may reduce it — they never increase it beyond the authoritative value. Some resolvers also respect the "minimum" TTL from the SOA record for negative caching (NXDOMAIN responses).
Understanding TTL helps troubleshoot DNS propagation issues. If you changed your domain's DNS records and visitors are still seeing the old site, it is likely because their resolver or OS is serving a cached record that has not yet expired. Waiting for the TTL to elapse, or flushing the local DNS cache, resolves this.
Browser DNS Cache
Modern browsers maintain their own DNS cache as a performance optimization. This is the first cache checked when you navigate to a website, making it the fastest path to a resolved IP address.
Google Chrome: Chrome maintains an internal DNS cache with a default TTL of 60 seconds, overriding the TTL set by the authoritative server. You can view cached entries by navigating to chrome://net-internals/#dns and clicking "Clear host cache" to flush. Chrome also supports DNS prefetching, which resolves domains for links it predicts you might click.
Mozilla Firefox: Firefox caches DNS results using its own network stack. The default cache duration is 60 seconds. Navigate to about:networking#dns to view cached entries. Firefox's network.dnsCacheExpiration preference in about:config controls the cache duration.
Apple Safari: Safari uses the macOS system cache via mDNSResponder rather than maintaining a separate browser cache. Clearing Safari's cache or the OS cache flushes DNS entries as well.
Microsoft Edge: Edge uses the Chromium engine and maintains a DNS cache similar to Chrome. It can be viewed at edge://net-internals/#dns.
Browser DNS caches are especially useful on devices that make many requests to the same domains, such as loading a modern webpage with dozens of third-party resources. However, they also mean that browser-level DNS issues require browser-specific flushing — clearing the OS cache alone will not affect browser-cached records.
OS DNS Cache
The operating system maintains a DNS cache shared by all applications. This cache persists after browser sessions end and applies to command-line tools, email clients, and any other network-aware software.
Windows: The DNS Client service (Dnscache) manages the OS cache. Entries are stored in memory and refreshed on each successful resolution. The cache size can reach thousands of entries on an active system. You can view and flush the cache using ipconfig /displaydns and ipconfig /flushdns respectively.
macOS: mDNSResponder handles DNS caching on macOS. It also provides mDNS (multicast DNS) and Bonjour services. The cache is flushed using sudo dscacheutil -flushcache followed by sudo killall -HUP mDNSResponder. Both commands are necessary to fully clear all cached records.
Linux: DNS caching behavior varies by distribution. Ubuntu and Fedora with systemd-resolved use resolvectl flush-caches. Older systems using nscd (Name Service Cache Daemon) flush with sudo service nscd restart. Some distributions do not cache DNS at the OS level by default.
Android: Android uses a DNS resolver managed by the Connectivity Service. There is no built-in command to flush the cache. Toggling Airplane Mode on and off or restarting the device effectively clears cached DNS entries.
iOS: iOS manages DNS through mDNSResponder, similar to macOS. There is no direct flush command. The standard approach is to toggle Airplane Mode or restart the device to clear cached records.
The OS cache is the most important layer to flush when you change DNS servers, update a domain's records, or troubleshoot connectivity issues. It affects all applications system-wide.
How to Flush DNS Cache
Windows (10 and 11)
Open Command Prompt or PowerShell as Administrator. Run the command ipconfig /flushdns. You will see a confirmation message: "Successfully flushed the DNS Resolver Cache." This clears the OS-level cache immediately. Browser caches must be cleared separately. See our Windows DNS flush guide for more details.
macOS
Open Terminal. Run the following commands sequentially:
sudo dscacheutil -flushcache && sudo killall -HUP mDNSResponder
You will be prompted for your admin password. The first command flushes the DNS cache, and the second restarts the mDNSResponder service to clear any remaining cached entries. This is required on macOS because mDNSResponder maintains multiple cache layers. See our Mac DNS flush guide for step-by-step instructions.
Linux
The command varies by distribution and DNS manager:
systemd-resolved (Ubuntu 18.04+, Fedora, Debian 9+): sudo resolvectl flush-caches
nscd (older distributions): sudo service nscd restart
dnsmasq: sudo systemctl restart dnsmasq
You can verify the cache is empty with resolvectl statistics. If "Current Cache Size" shows 0, the flush was successful. See our Linux DNS flush guide for more information.
iPhone and iPad
iOS does not provide a command to flush DNS cache directly. The simplest method is to toggle Airplane Mode: enable Airplane Mode, wait 10 seconds, then disable it. This forces the OS to discard cached DNS entries. Alternatively, restart the device. Another option is to go to Settings, Wi-Fi, tap the "i" icon next to your network, and tap "Renew Lease." This releases the DHCP lease and clears associated DNS cache entries. For a deeper approach, see our complete DNS cache flush guide.
Android
Android does not have a built-in DNS flush command. Toggle Airplane Mode on and off to force a DNS cache clear. As a more thorough alternative, go to Settings, Network and Internet, Private DNS, and temporarily switch between "Off" and your preferred DNS provider. This forces the resolver to re-resolve all cached entries. Restarting the device also clears the cache.
For additional details on each platform, see our comprehensive DNS cache flush guide.
DNS Cache and Privacy
DNS cache has important implications for your privacy. While caching improves speed and reduces network traffic, it also creates a local record of your browsing activity that persists on your device.
What your DNS cache reveals: A DNS cache entry contains the domains you have visited and their resolved IP addresses. Anyone with access to your device — whether physically, through malware, or via a forensic examination — can read this cache to reconstruct a timeline of your browsing activity. On Windows, running ipconfig /displaydns displays every cached domain in plaintext.
Browser cache exposure: Browser DNS caches add another layer of exposure. Chrome's net-internals page, Firefox's about:networking page, and Edge's net-internals page all expose cached DNS records to anyone who can open those pages on your device.
Privacy protection through flushing: Regularly flushing your DNS cache removes this local record of your browsing activity. While it does not prevent your DNS resolver from seeing your queries, it limits the local footprint. This is especially valuable on shared or public computers.
Combining cache hygiene with encrypted DNS: For maximum privacy, combine regular DNS cache flushing with DNS over TLS (DoT) or DNS over HTTPS (DoH). Encrypted DNS prevents network observers from seeing your queries in transit, while cache flushing limits what is stored locally. Together, they significantly reduce your DNS-related privacy exposure.
Private browsing modes: Most browsers clear their DNS cache when you close a private/incognito window. However, this does not clear the OS-level cache. For complete privacy, flush both the browser and OS cache, and use encrypted DNS to prevent your resolver from logging your queries.
Frequently Asked Questions
What is DNS cache?
DNS cache is a temporary storage of DNS lookup results maintained by your browser, operating system, and DNS resolver. When you visit a domain, the IP address is stored locally so subsequent lookups for the same domain skip the full recursive resolution process, resulting in faster page loads.
How long does DNS cache last?
DNS cache duration is controlled by the TTL (Time To Live) value set by the domain owner, typically ranging from 300 seconds (5 minutes) to 86400 seconds (24 hours). Browser caches may override this with their own expiry policies. Flushing DNS cache clears all entries regardless of their remaining TTL.
How do I flush my DNS cache?
On Windows, open Command Prompt and run ipconfig /flushdns. On Mac, open Terminal and run sudo dscacheutil -flushcache && sudo killall -HUP mDNSResponder. On Linux, use sudo resolvectl flush-caches for systemd-based systems. On mobile devices, toggle Airplane Mode on and off or restart the device.
Is it safe to flush DNS cache?
Yes, flushing DNS cache is completely safe. It does not delete any personal files, browsing history, or settings. It only clears stored DNS records, which will be re-resolved on your next visit. You may notice a one-time slowdown of a few milliseconds on your first request to a site after flushing, but everything will work normally.