Skip to main content
Tech Tutorials & Programming8 min readDec 5, 2025

What Is DNS Caching? How It Works and How to Clear It

Zeid Abughazaleh
Zeid Abughazaleh

Dec 5, 2025

Quick Answer

DNS caching is the temporary storage of DNS lookup results so devices, browsers, routers, and DNS resolvers do not need to repeat the full lookup process every time a domain is visited. Cached DNS records map domain names to IP addresses and remain stored until their Time to Live (TTL) expires or the cache is cleared.

DNS caching helps reduce lookup time, lower DNS traffic, and improve browsing performance, but outdated or incorrect cached records can sometimes cause connection problems.

Key Takeaways

  • DNS caching stores DNS lookup results temporarily so repeated requests can be answered faster.
  • Cached records can exist in the browser, operating system, router, and recursive DNS resolver.
  • TTL (Time to Live) determines how long a DNS record remains cached before it must be refreshed.
  • DNS caching helps reduce latency, speed up DNS resolution, and lower the number of requests sent to DNS servers.
  • Cached DNS records do not store website pages, images, or other content, so DNS caching does not provide offline access.
  • Outdated cached records can temporarily cause a domain to resolve to an old or unavailable IP address.
  • Flushing the DNS cache is generally safe and is mainly useful when troubleshooting DNS or connectivity problems.
  • Using a proxy does not automatically bypass DNS caching; DNS resolution may happen locally or through the proxy depending on the application and proxy configuration.

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:

  1. 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.
  2. Cache storage: After the domain is resolved, the DNS record may be temporarily stored by your browser, operating system, router, or recursive DNS resolver.
  3. Subsequent requests: Until the record’s Time to Live expires, future requests can use the cached result instead of repeating the complete lookup process.
Image of a server with TTL written on it and three buttons to the side showing a clock, a checkbox, and a stop sign. Text above reads

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:

  1. TTL is set by the authoritative DNS servers for each record.
  2. 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:

  1. 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.
  2. 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.
  3. 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.
  4. 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.
  5. 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.
  6. Authoritative DNS Server: Helps authoritative servers provide faster responses of certain types of queries, including those in more complex DNS setups.
  7. 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.
  8. Host File: Acts as the manual override for the DNS resolution where the system will first check the hosts file before making a query.
Image of a computer screen showing a folder reading DNS and a FLUSH button under it. Text above reads

What Is DNS Cache Poisoning?

DNS cache poisoning is an attack in which false DNS records are inserted into a DNS resolver’s cache. When users request a legitimate domain, the poisoned cache can return an incorrect IP address and redirect them to an unintended or malicious destination.

DNS cache poisoning is different from a normal stale DNS record. A stale record usually results from an outdated cached entry, while cache poisoning involves deliberately inserting incorrect DNS information.

Then remove the existing DNS cache poisoning paragraph from the “How to Clear DNS Cache” section so you’re not repeating it.

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

  1. Open your Terminal and enter sudo killall -HUP mDNSResponder
  2. 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

  1. Open Command Prompt by clicking Start, Windows Systems, Command Prompt.
  2. 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)

  1. Click on Activities and search for Terminal.
  2. 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.

FAQ

Got questions?
We've got answers.

Quick answers to the most common questions about this topic.

DNS cache duration depends on the record’s Time to Live (TTL), which is set by the authoritative DNS server. A record may remain cached for a few seconds, several minutes, hours, or longer. Once the TTL expires, the resolver must retrieve an updated DNS record the next time the domain is requested.

Yes. Flushing your DNS cache is generally safe. It removes locally stored DNS records and forces your device to request fresh DNS information. The first connection to a domain afterward may take slightly longer because a new DNS lookup is required.

Clearing the DNS cache removes stored domain-to-IP address mappings from your device. When you visit a website again, your system performs a new DNS lookup instead of using the previously cached result. This can help fix problems caused by outdated or incorrect DNS records.

Yes. An outdated DNS cache can temporarily direct a device to an old or unavailable IP address after a domain’s DNS records have changed. Clearing the cache can help if a website works on other devices or networks but not on yours.

DNS cache poisoning is an attack in which false DNS information is inserted into a resolver’s cache. This can cause users requesting a legitimate domain to be redirected to an unintended or malicious destination. It is different from a normal stale DNS record.

Not necessarily. DNS records may still be cached by your browser, operating system, router, or DNS resolver when using a proxy. Whether DNS resolution happens locally or through the proxy depends on the proxy protocol and how the application is configured.

Ready to launch?

Proxies built for real operations.

For teams that depend on stability, not luck.