Network security

What Is DNS Cache? How It Works, TTL, Flushing and Poisoning

Every time you visit a site, your device remembers the address — for a while. That memory is the DNS cache, and it is why repeat visits feel instant.

Cysoro Security TeamPublished · 8 min read
example.com→ 93.184.216.34cysoro.com→ cached · TTL 300syour-site.com→ fresh lookup… NETWORK SECURITY DNScache Remembered addresses, faster visits.
Quick answer

A DNS cache is a temporary store of recent DNS answers — domain names matched to IP addresses — kept by your browser, operating system, router or resolver so repeat lookups return instantly instead of querying the internet again. Each answer is kept for its TTL (time to live), a number of seconds set by the domain owner. When the TTL expires, the entry is discarded and the next lookup starts fresh.

Key takeaways

  • A DNS cache stores recent name-to-address answers at four layers: browser, operating system, router and resolver.
  • TTL, set by the domain owner in seconds, controls how long each cached answer stays valid.
  • Flushing the cache only clears your own device — it cannot clear your router's or your ISP's cache.

The first visit to a new website is slightly slower than the tenth. That is not your imagination — your device remembers the address after the first lookup, and that memory is the DNS cache.

What is a DNS cache?

A DNS cache is a temporary store of DNS answers that your browser, operating system, router or resolver keeps so repeat lookups return instantly instead of asking the internet again. Each stored answer pairs a domain name with the IP address it resolved to.

Cloudflare describes it plainly: after a recursive resolver retrieves the correct IP address for a website, it stores that information in its cache for a limited time. During that time, if any other client asks for the same domain, the resolver can skip the typical lookup process and answer from the cache, as explained in Cloudflare's DNS server guide.

The cache exists because a full lookup is expensive. Without caching, every visit would query a root server, then a top-level-domain server, then the domain's authoritative nameserver — a round trip that typically costs tens to hundreds of milliseconds. With caching, the second visit costs almost nothing.

How does DNS caching work?

A lookup follows a fixed sequence, and caching happens at every layer the answer passes through. Understanding the sequence explains almost every DNS problem you will ever meet.

  1. An application asks for a name. A browser loads example.com, or a program calls the system resolver.
  2. Local caches are checked first, in order. Browser cache, then the operating system cache, then the configured DNS server — often the router, or a public resolver such as 1.1.1.1 or 8.8.8.8 — and then that resolver's own cache.
  3. On a cache miss, a recursive query runs. The resolver asks a root server for the TLD nameserver, asks the TLD server for the authoritative nameserver, then asks the authoritative server for the actual record.
  4. The answer is cached at every layer it passed through, each layer storing it against the record's TTL and counting down independently from the moment it was cached.
  5. Later requests inside the TTL window are answered directly from whichever cache still holds a valid entry, with no network round trip to the authoritative server.

Each layer counts down on its own clock. That is why the same name can resolve differently from two machines at the same moment: one machine's cache expired and fetched the new address, while the other's still holds the old one.

The lookup chain — caches are checked in orderBrowserown cache,about 60 secOperatingsystemDNS ClientserviceRouterhome networkforwarder cacheResolverISP or public1.1.1.1 / 8.8.8.8Author-itativeserverA hit at any layer ends the lookup. A miss at every layer walks the full chain.Each layer caches the answer and counts its TTL down independently.Flushing one layer does not clear the others.
The four cache layers a lookup passes through, in order. Illustration by Cysoro.

What is TTL and how does it control the cache?

TTL stands for time to live. It is a field in every DNS resource record — a number in seconds, set by whoever manages the domain — that tells a resolver how long it may reuse the answer before asking again.

RFC 1035, the original DNS standard, defines TTL as the interval a record may be cached before the source of the information should again be consulted. A TTL of 3600 means one hour; a TTL of 300 means five minutes; a TTL of zero means the answer must never be cached at all.

Cloudflare's documentation gives practical numbers: proxied records have a TTL of Auto, set to 300 seconds, so changes to an assigned IP take effect quickly. For unproxied records you can choose a TTL between 60 seconds and one day. Longer TTLs speed up lookups by increasing the chance of a cached result, but they also mean updates take longer to reach your users.

That trade-off is the central decision in DNS management. A long TTL (a day or more) is good for stable records that rarely change, because it reduces load and speeds up visits. A short TTL (five minutes) is good before a migration, a failover or any planned change, because it lets you move fast when the time comes.

What is the difference between DNS cache and TTL?

TTL is a value; the cache is the mechanism that reads and obeys it. People use the two terms interchangeably, but they describe different things.

TTL is set by the domain owner in the DNS record itself. The cache is the storage on your device, router or resolver that holds the answer and counts the TTL down. When the countdown reaches zero, the cached answer is discarded and the next lookup queries the authoritative server again.

A useful way to think about it: TTL is the expiry date printed on the carton, and the cache is the fridge. Changing the expiry date on future cartons does nothing to the milk already in the fridge — it still expires on its original date. That is exactly why lowering a TTL does not speed up a change that is already cached.

How do you flush the DNS cache?

Flushing the DNS cache means deleting the locally stored answers so the next lookup goes out to the network again. It is the standard first step when a site will not load, shows an old version, or resolves to the wrong server after a change.

PlatformCommand or steps
WindowsOpen an elevated Command Prompt and run ipconfig /flushdns
Windows PowerShellRun Clear-DnsClientCache as administrator
macOSRun sudo dscacheutil -flushcache then sudo killall -HUP mDNSResponder
Linux (systemd-resolved)Run resolvectl flush-caches
Chrome / EdgeOpen chrome://net-internals/#dns and click Clear host cache
RouterRestart the router, or clear its DNS cache in the admin panel

Microsoft's ipconfig documentation states that /flushdns flushes and resets the contents of the DNS client resolver cache, and that it can discard negative cache entries as well as ordinary ones. See the Microsoft Learn ipconfig reference. To see what is cached before you flush, run ipconfig /displaydns.

Remember the limit: flushing clears your own device only. It does nothing to the cache your router or your ISP is still holding, and it does nothing for anyone else's machine. If a site still shows the old address after a flush, wait out the TTL or restart the router.

You can check what a domain currently resolves to with our free DNS lookup tool.

You can also see who owns the domain with the WHOIS lookup.

What is negative caching?

A resolver does not only cache records that exist. If a query comes back with no such name (NXDOMAIN) or with no record of the type asked for, that failure gets cached too. This is called negative caching, and it is defined in RFC 2308.

The lifetime of a negative entry comes from the zone's SOA record: the smaller of the SOA record's TTL and its minimum field, capped in practice at roughly one to three hours. That is why a brand-new domain can stay unreachable for a while after you create it — resolvers that asked too early are still holding the "does not exist" answer.

Negative caching also explains a common support headache: a typo in a DNS record, fixed minutes later, keeps failing for some users until the negative entry expires. Flushing your own cache helps you, but other people's resolvers must wait out their own timers.

What is DNS cache poisoning?

DNS cache poisoning, also called DNS spoofing, is an attack in which false information is inserted into a DNS cache. A poisoned cache sends visitors to the attacker's server instead of the real one, so they see a fake site — often a convincing copy designed to steal logins or payment details.

Classic poisoning works by racing the real answer: the attacker floods the resolver with forged replies, hoping one arrives first and gets cached. Modern resolvers use randomized source ports and transaction IDs to make that race hard to win, and DNSSEC adds cryptographic signatures so a resolver can verify that an answer really came from the authoritative server.

For a home user, the practical defenses are simple: use a reputable resolver such as 1.1.1.1 or 8.8.8.8, keep your router firmware updated, and use DNSSEC validation where your resolver supports it. For a domain owner, the defense is to sign your zone with DNSSEC — check whether a domain is protected with our DNS lookup tool.

Clean cache vs poisoned cacheClean cacheexample.com → 93.184.216.34answer verified, within TTLvisitor reaches the real site✓ DNSSEC can prove itPoisoned cacheexample.com → attacker IPforged answer cached firstvisitor reaches a fake site✗ looks real, steals loginsDefenses: reputable resolvers, randomized ports, DNSSEC validation and signing.
A poisoned cache sends visitors to a fake site that looks real. Illustration by Cysoro.

Why do DNS changes take time to appear?

DNS changes do not propagate like a broadcast — they expire, cache by cache. When you change a record, every resolver that already holds the old answer keeps serving it until its TTL runs out. Only then does it fetch the new one.

That is why a change with a 24-hour TTL can take a full day to reach everyone, while the same change with a 300-second TTL reaches most users within minutes. The delay is not a fault in the system; it is the cache behaving exactly as the protocol prescribes.

To make a planned change go smoothly, lower the TTL to 300 seconds a day or two before the change, wait for the old long-TTL entries to expire, make the change, and then raise the TTL back up afterwards. That is the standard practice for migrations, failovers and hosting moves.

Common DNS cache mistakes

The most common mistake is flushing the wrong layer: clearing the browser cache when the stale answer lives in the operating system, or flushing the operating system when the stale answer lives in the router. Work through the layers in order, and test after each one.

Another mistake is assuming a flush fixes a DNS problem. Flushing is cleanup, not a cure — the durable fixes are correct records, sensible TTLs and DNSSEC. If a site keeps resolving wrongly after a flush, the record itself, the resolver or the network path is the problem, not your cache.

Finally, do not set very long TTLs on records you may need to change quickly, such as the address of a server you might fail over. A 48-hour TTL on a failover record means a 48-hour wait when it matters most.

The bottom line

A DNS cache is a simple idea with a big effect: store recent answers, reuse them until the TTL expires, and skip the full lookup next time. It makes the internet fast, and it explains why changes take time, why a flush sometimes helps, and why poisoning is so dangerous.

Next time a site shows an old version or will not load at all, check the current answer with the free DNS lookup tool — and if you run a domain of your own, keep TTLs short before a change and sign the zone with DNSSEC.

Frequently asked questions

What is a DNS cache in simple terms?

A DNS cache is your device's short-term memory for website addresses. After it looks up a domain name once, it stores the answer so the next visit to the same site does not need a fresh lookup. The answer is kept only for its TTL, then discarded.

Where is the DNS cache stored?

In four places: your browser keeps its own small cache, your operating system keeps a resolver cache, your router keeps a cache for your home network, and your ISP or public resolver keeps a shared cache. Each layer has its own lifetime and its own way to clear it.

How long does DNS cache last?

It depends on the record's TTL, which the domain owner sets in seconds. Common values range from 300 seconds (five minutes) to 24 or 48 hours. Cloudflare's default for proxied records is 300 seconds. Browser caches are often much shorter, around 60 seconds.

How do I flush my DNS cache?

On Windows, run ipconfig /flushdns in an elevated Command Prompt. On macOS, run sudo dscacheutil -flushcache followed by sudo killall -HUP mDNSResponder. On Linux with systemd-resolved, run resolvectl flush-caches. In Chrome, open chrome://net-internals/#dns and click Clear host cache.

Is it safe to flush the DNS cache?

Yes. Flushing only deletes stored lookup results, so the next visit to each site does a fresh lookup. It does not change your settings, delete files or harm your device. The only effect is that the next few lookups are slightly slower.

What is DNS cache poisoning?

DNS cache poisoning is an attack in which false information is inserted into a DNS cache, so a domain name resolves to the attacker's server instead of the real one. Victims are then sent to a fake site. DNSSEC and hardened resolvers are the main defenses.

Why does a website change take time to appear?

Because caches keep serving the old answer until its TTL expires. This delay is called DNS propagation, and it is really just every cache in the chain expiring on its own schedule. Lowering the TTL before a planned change shortens the delay.

What is negative DNS caching?

Negative caching means storing the answer that a name does not exist, such as an NXDOMAIN response. It is defined in RFC 2308 and its lifetime comes from the zone's SOA record. It is why a brand-new domain can stay unreachable for a while after you create it.

Sources

  1. Cloudflare — What is a DNS server?
  2. Cloudflare — Time to Live (TTL)
  3. Microsoft Learn — Ipconfig
Written & fact-checked byCysoro Security Team

The engineers and analysts who build Cysoro's domain scanner, email-authentication checks and free security tools. We test what we write about every day — SPF, DKIM, DMARC, certificates, look-alike domains and phishing — and check each guide against the relevant standards, government guidance and vendor documentation.

  • Email authentication
  • Phishing & BEC
  • Domain & DNS security
  • Small-business security

Checked against Cloudflare's DNS and TTL documentation and Microsoft's ipconfig documentation.

How we write and fact-check →

Free tools for this topic

No account needed.

See where your domain stands

Free for up to 3 domains. No card, no installs.

Start free