DNS Caching Explained
How a DNS Cache Stores Answers
A DNS cache is a temporary store of DNS answers. It keeps results so that repeated lookups for the same name do not need a full query each time. When a lookup succeeds, the answer is saved along with its TTL, and any device or server holding it can reply to the next request from memory.
Caching is why most lookups are fast. A single web page can involve many names, and millions of people look up the same popular names every day. Without caches, every request would travel to the authoritative servers and back, adding delay and load across the whole internet.
The Layers That Store DNS Answers
A single lookup can pass through several caches before it reaches the authoritative server:
- Browser cache: the web browser keeps recent lookups for a short time.
- Operating system cache: the system’s DNS client stores answers for all programs on the device.
- Router or local resolver: many home and office routers run a small resolver that caches answers for every device behind them.
- Recursive resolver: the server that does the lookup work, such as one run by an internet provider or a public service, caches answers for all of its users. This is usually the largest cache in the chain.
Resolvers also cache delegation records, the NS records that point to the servers for each parent zone. That is why a resolver rarely has to ask the root servers again for a domain it has seen recently.
Why Stale Answers Happen
A stale answer is an old record that keeps being served after the real record has changed. It happens because each layer keeps its own copy and drops it only when the TTL runs out. A device may keep using an old address after the website has moved, even though the resolver has already updated.
Negative answers are cached too. A name that did not exist a moment ago may still fail for some users after it is created. Because caches are separate, a problem on one computer is usually local, while a problem in a shared resolver can affect everyone who uses it. A local override in the hosts file bypasses this whole chain, which is why it can cause confusion when an entry is forgotten.
Frequently asked questions
Does clearing the DNS cache fix a website that will not load?
Sometimes. Clearing the local cache removes old answers from your own device, which helps if your computer was holding an outdated address. It does nothing for caches elsewhere, such as your provider’s resolver, which expire on their own schedule. If a site is down for everyone, clearing your cache will not bring it back. For why changes reach visitors at different times, see DNS propagation.
Is a DNS cache the same as a browser cache?
No. A DNS cache stores name-to-address answers, while a browser cache stores website files such as images, scripts and pages. Browsers do keep a short-lived DNS cache of their own, but the two work separately and are cleared separately.