DNS caching is the process of temporarily storing the results of DNS lookups in a local memory on devices, browsers, or servers. This makes future visits to the same site load faster by avoiding repeated lookups, reducing network traffic, and improving performance. We will explain what DNS caching is, what Time to Live (TTL) is, and how you can clear your cache.
There are several types of caching in the DNS system. When a user or machine starts a DNS request, the response may be stored in the temporary memory or cache of the user’s operating system and browser. Each record has a time-to-live (TTL) value that dictates how long records can be stored in a cache before being deleted.
When a user starts a DNS query, their device will check the local cache in the operating system or browser to see if the record already exists. If it does not, it will forward the request to a recursive DNS server. The server will either resolve the request based on the information stored in its own cache, or it will forward it to other nameservers and eventually to the authoritative server.
The response from the authoritative DNS server is stored in the cache of each resolver step and forwarded back to the device. This will load the correct web page or connect to the correct device.
Storing DNS responses in a cache provides several benefits. Future requests for the same domain can be answered without repeating the complete DNS lookup process, which can reduce latency, lower the number of requests sent to DNS servers, and improve browsing performance.
However, DNS caching does not make websites available offline. It only stores information about how a domain name maps to an IP address; it does not store the website’s pages, images, or other content.
DNS caching generally works in three steps:
- First request: When you visit a website, your device must find the IP address associated with its domain name. If the answer is not already cached, a DNS resolver performs the lookup.
- Cache storage: After the domain is resolved, the DNS record may be temporarily stored by your browser, operating system, router, or recursive DNS resolver.
- Subsequent requests: Until the record’s Time to Live expires, future requests can use the cached result instead of repeating the complete lookup process.

What is TTL in DNS?
Time to Live (TTL) in DNS dictates how long DNS records should be stored in the cache memory before it is considered outdated and must be deleted. It is typically measured in seconds. The functions of TTL in DNS caching are as follows:
- TTL is set by the authoritative DNS servers for each record.
- When a query is resolved, the TTL countdown begins. After the TTL expires, the cached record is considered stale and the resolver must request an updated answer the next time the domain is queried.
TTL balances performance and accuracy. Longer TTL values reduce the number of DNS lookups, while shorter TTL values allow DNS record changes to reach users more quickly. If a cached record becomes outdated, it may temporarily direct a connection to an old or unavailable IP address until the record expires or the cache is cleared. Longer TTL values reduce the number of DNS lookups, while shorter TTL values allow changes to DNS records to reach users more quickly. If a cached record becomes outdated, it may temporarily direct a connection to an old or unavailable IP address until the record expires or the cache is cleared.
There are eight types of DNS caching, each with its own unique functions. They are:
- Browser-Level: This allows the browser to quickly resolve the domain names without needing to query operating systems or external DNS servers again which will reduce latency.
- Operating System-Level: This cache serves as the next line of the resolution if the browser cache does not have the required DNS record. It will reduce the need for external DNS lookups.
- Router-Level: Allows the router to the server to store DNS queries locally for all the connected devices and improves the network efficiency while reducing the number of external DNS queries.
- DNS Resolver (ISP/Third-Party DNS Server): Serves the broader user base and reduces the need to query authoritative DNS servers repeatedly while improving the resolution times for multiple users.
- Recursive Resolver: Helps reduce load on DNS infrastructure by storing results of the queries which will be used to answer future requests from any client.
- Authoritative DNS Server: Helps authoritative servers provide faster responses of certain types of queries, including those in more complex DNS setups.
- Content Delivery Network: Helps CDNs resolve the domain names quickly and directs users to the nearest server with the cached content. It improves load times and reduces latency.
- Host File: Acts as the manual override for the DNS resolution where the system will first check the hosts file before making a query.

How to Clear DNS Cache
Clearing—or flushing—a DNS cache removes locally stored DNS records and forces the device to request updated information during future lookups.
You may need to flush your DNS cache when a website has changed its IP address, a domain works on other devices but not yours, you recently changed your DNS provider, or you are troubleshooting a DNS-related connectivity problem.
Flushing the DNS cache is generally safe. However, the first visit to a domain afterward may take slightly longer because the device must perform a new DNS lookup.
DNS cache poisoning is different from an ordinary outdated cache. It is a security attack in which false DNS information is inserted into a resolver’s cache, potentially redirecting users to an unintended destination.
macOS
- Open your Terminal and enter sudo killall -HUP mDNSResponder
- After that, you will be prompted to enter your password.
Keep in mind that the command you enter changes depending on your macOS. The command we provided is for version 10.11 and above.
Windows
- Open Command Prompt by clicking Start, Windows Systems, Command Prompt.
- Enter this command ipconfig /flushdns
Keep in mind that the command you enter changes depending on your operating system. The command we provided is for Windows 10.
Linux (Ubuntu)
- Click on Activities and search for Terminal.
- Enter this command sudo resolvectl flush-caches
For other distributions, the command is sudo /etc/init.d/dns-clean start
How Does DNS Caching Affect Proxy Connections?
Using a proxy does not automatically clear or bypass every DNS cache. DNS records may still be cached by the browser, operating system, router, application, or DNS resolver.
This can become noticeable when changing proxy endpoints or locations. For example, a device may temporarily continue using a previously cached DNS response even after the proxy IP has changed. Flushing the local DNS cache can help when troubleshooting these situations, although it will not resolve issues caused by the proxy server itself.
Where DNS resolution occurs depends on the proxy protocol and application configuration. Some applications resolve the domain locally before connecting through the proxy, while others can send the hostname through the proxy for remote resolution.
This distinction applies to mobile, residential, and datacenter proxies. The proxy category does not, by itself, determine where DNS resolution or caching happens.
Conclusion
DNS caching temporarily stores the results of DNS lookups so that browsers, devices, and resolvers do not need to repeat the complete resolution process for every request. Each cached record remains available according to its TTL value.
Caching generally improves performance and reduces unnecessary DNS traffic. However, an outdated record can occasionally cause a website to resolve to an old or unavailable IP address. When that happens, flushing the local DNS cache may help retrieve an updated record.
Key Takeaways
- DNS caching temporarily stores domain-to-IP address mappings.
- Cached records can reduce lookup times and DNS server traffic.
- TTL determines how long a DNS record may remain cached.
- DNS caching does not store website content or provide offline access.
- Users normally only need to flush their DNS cache when troubleshooting.
- Using a proxy does not automatically bypass local DNS caching.
- DNS resolution may happen locally or through the proxy, depending on the application and proxy configuration.