TEZZ CONNECTBlog

Blog / Internet Technology & Updates / DNS Caching

THE TEZZ CONNECT NETWORKING SERIES

How DNS Caching Works: TTL, Negative Caching and Resolver Behaviour

DNS caching makes the internet faster and more resilient, but it can also explain why a DNS change is not visible everywhere at once. Learn how TTLs, positive and negative answers, resolver caches and serve-stale behaviour work—and how to troubleshoot them.

By Suraj Vishwakarma · Published by TEZZ CONNECT · Published 27 November 2026 · Updated 30 November 2026

Close-up of a wireless router and its antennas
Photo: Unsplash · Image source

When you open a website for the second time, it often feels faster than the first. One reason may be that your device or a DNS resolver already knows the answer to the domain-name lookup. Instead of asking the DNS hierarchy to find the same information again, a cache can reuse data that is still valid.

DNS caching is one of the quiet mechanisms that makes the internet practical at global scale. It reduces repeated queries, lowers response time, limits unnecessary traffic to authoritative name servers and can help services remain available during temporary upstream problems. But caching also explains a familiar frustration: after a website owner changes a DNS record, one person sees the new destination while another still reaches the old one.

The key concept is the Time to Live (TTL). A DNS record's TTL tells a cache how long it may reuse that record before it must obtain fresh information. The real picture is more involved: different record sets can have different TTLs; recursive resolvers, operating systems, browsers and applications may maintain separate caches; negative answers can also be cached; and some resolvers can deliberately serve expired data during an outage.

This guide explains the complete lifecycle in practical language. It distinguishes standards-defined behaviour from implementation choices, shows how to reason about common DNS symptoms, and provides examples for website owners, network administrators and everyday users. It is an original educational explanation, not a substitute for the documentation of a particular DNS provider or resolver.

1. What is DNS caching?

The Domain Name System (DNS) maps names such as example.com to records that applications need. An A record can provide an IPv4 address; an AAAA record can provide an IPv6 address; an MX record identifies mail exchangers; a CNAME record creates an alias; and other record types support services and policies.

A recursive resolver performs the work of finding an answer on behalf of a client. It may contact root, top-level-domain and authoritative name servers, follow referrals and assemble the response. If it stored no answers, it would repeat much of this work for every request. Popular names would generate enormous volumes of repetitive traffic.

A cache stores DNS information temporarily so it can be reused. If another client asks for the same relevant information while the cache entry remains valid, the resolver can answer locally instead of repeating the entire lookup. The result is often lower lookup latency and fewer upstream queries.

For example, imagine a recursive resolver receives a query for www.example.net. It obtains an A record with a TTL of 600 seconds. A second user behind the same resolver asks for the same record 20 seconds later. The resolver may return the cached address with approximately 580 seconds remaining, rather than starting from the root again.

DNS caching is not a single computer-wide memory. There may be several layers:

  • Recursive resolver cache: maintained by a home router, ISP, enterprise DNS server or public DNS service.
  • Operating-system cache: some operating systems keep recently resolved names locally.
  • Browser or application cache: browsers and software may retain DNS results or use their own resolution mechanisms.
  • Intermediate network caches: enterprise gateways and specialised DNS infrastructure may add additional layers.

Not every device uses every layer. A browser may use the operating system's resolver, a configured encrypted-DNS service, or an application-specific networking stack. This is why clearing one cache does not necessarily clear all cached DNS information.

2. What does DNS TTL mean?

TTL means Time to Live. In DNS, it is a duration expressed in seconds that indicates how long a resource record may be cached. It is not the time until a domain registration expires, the age of a website, or a promise that a DNS change will become visible to everyone at the same instant.

Consider an A record configured with a TTL of 3,600 seconds. A resolver that receives the record can generally reuse it for up to one hour. As time passes, the remaining TTL decreases. If the record is cached for 15 minutes, a later response might show approximately 2,700 seconds remaining.

Configured TTLApproximate durationCommon interpretation
60 seconds1 minuteShort caching window; useful for some planned changes, but creates more refresh traffic.
300 seconds5 minutesA relatively short operational window.
900 seconds15 minutesA moderate short-term cache duration.
3,600 seconds1 hourA common general-purpose duration.
86,400 seconds24 hoursA long cache window; changes may take longer to be reflected by caches that already hold the old answer.

These are examples, not universal recommendations. The appropriate TTL depends on how frequently records change, how much query volume the authoritative service must handle, the provider's own limits and the operational consequences of stale data.

TTL is attached to DNS resource records, not to an entire domain as one indivisible timer. An A record, AAAA record, MX record and TXT record may have different TTL values. Even records returned in one DNS response can have different TTLs.

A TTL of zero means the record should not be retained for later cache reuse; it can still be used for the transaction in progress. In practice, resolver policies and provider limits can affect the effective cache lifetime. Some services impose minimum or maximum TTLs, so the value configured at an authoritative provider may not be the only value that matters.

3. How a recursive resolver uses its cache

A recursive resolver typically checks its cache before doing a fresh iterative lookup. A simplified sequence looks like this:

  1. A client asks the configured resolver for a record, such as the A record for shop.example.com.
  2. The resolver checks whether it has a usable cached answer for the relevant name, record type and class.
  3. If a valid answer exists, the resolver returns it and reports the remaining TTL.
  4. If there is no usable answer, the resolver performs the necessary DNS resolution steps, following referrals and contacting authoritative servers.
  5. The resolver stores eligible response data according to DNS rules and its cache policy.
  6. Later queries can reuse the cached data until it expires or is otherwise removed.

DNS caching is more sophisticated than simply remembering one IP address per domain. A resolver can cache delegation information, name-server addresses, aliases, address records, DNSSEC-related records and negative answers. The cache key and the way records are combined depend on DNS semantics, including the queried name, type and class.

For example, an application asking for an AAAA record is not necessarily asking the same question as one asking for an A record. A cached A record does not automatically answer an AAAA query. Likewise, a CNAME chain may require several records, each with its own TTL and cache state.

Resolvers can also keep infrastructure information such as name-server reachability or failure state. Those entries are not ordinary positive DNS answers, and standards place specific limits on some failure-caching behaviours.

4. Positive caching: when a DNS answer exists

Positive caching means caching a response that contains the requested data. Suppose www.example.com resolves to 203.0.113.25 and the A record has a TTL of 300 seconds. A resolver can reuse the answer during the valid caching period.

When a cached response is returned, its TTL should reflect the remaining lifetime, not restart from the original configured value. If a resolver received a 300-second record 100 seconds ago, it should not normally tell a downstream cache that the record has a fresh 300 seconds remaining. Doing so could extend the data's life unintentionally.

Positive caching is useful for performance, but it creates a trade-off during changes. If an administrator changes an address while caches still hold the previous answer, some clients may continue using the old destination until their cached entry expires. The authoritative server can publish the new answer immediately, but it cannot reach into every independent cache and erase an entry already stored elsewhere.

This is the reason DNS changes are often described as needing time to propagate. DNS does not usually push a global update to every resolver. Instead, caches age out and refresh when necessary. The phrase propagation is convenient shorthand, but it can hide the fact that each cache has its own query history and expiry time.

5. Negative caching: why a missing record can remain missing

DNS can return a useful answer even when the requested data does not exist. Two important negative outcomes are NXDOMAIN and NODATA.

  • NXDOMAIN: the queried domain name does not exist in the relevant DNS context.
  • NODATA: the name exists, but it has no record of the requested type. For example, a name may have an A record but no AAAA record.

Negative caching stores these answers temporarily. Without it, a client repeatedly asking for a name that does not exist could force resolvers to repeat the same upstream work. Negative caching reduces unnecessary queries and helps protect authoritative infrastructure.

RFC 2308 defines negative caching for DNS. For authoritative NXDOMAIN and NODATA responses, the authority section includes the zone's Start of Authority (SOA) record. The negative TTL is derived from the lower of the SOA record's TTL and the SOA MINIMUM field. The resolver decrements that lifetime as it caches the negative answer.

This has a practical consequence for new records. Imagine an administrator checks new.example.com before creating it. The resolver receives NXDOMAIN and caches that negative answer. The administrator then creates the A record. The authoritative zone now contains the record, but the resolver may continue returning the cached NXDOMAIN until the negative cache entry expires.

The user may describe this as DNS refusing to recognise a newly created record. The authoritative data may already be correct; the resolver is following the negative answer it previously cached. Waiting for the negative TTL or checking through a resolver that has not cached the old answer can help identify the difference.

NXDOMAIN and NODATA are not interchangeable. NXDOMAIN concerns the name's existence, while NODATA concerns the requested record type. Their cache matching rules differ, which is important for correct resolver behaviour.

6. DNS resolution failures are also cached

A negative answer is not the same as a resolution failure. If a resolver receives an authoritative NXDOMAIN response, it has information that the name does not exist. If the resolver times out because an authoritative server is unreachable, it has not learned whether the name exists.

Under RFC 9520, a resolution failure is determined for the queried name, type and class when none of the available servers provides useful response data. A timeout from one server does not by itself establish a resolution failure if another available server returns a usable answer. NXDOMAIN and NOERROR/NODATA are useful negative answers, not resolution failures.

RFC 9520, published in December 2023, addresses caching of DNS resolution failures. It requires resolvers to implement a cache for resolution failures so repeated queries do not continuously trigger upstream attempts that are already known to be failing. It requires failures to be cached for at least one second and limits their caching duration to no more than five minutes, consistent with RFC 2308. The implementation may distinguish failure types and cache them differently.

This matters during incidents. A resolver may temporarily remember that a particular server or validation path is failing. A user can therefore see a short-lived error even after the underlying network condition begins to recover. Conversely, caching can reduce pressure on an already struggling DNS infrastructure.

Do not assume every SERVFAIL is cached in exactly the same way by every resolver. The standards define requirements and limits, while implementations determine some details of the cache key and failure categories. Resolver documentation is important when diagnosing persistent or unusual behaviour.

7. Serve-stale: when a resolver uses expired DNS data

Ordinarily, once a cached record's TTL expires, a resolver should obtain fresh authoritative information before continuing to use it. But what if every authoritative server is temporarily unreachable? Strictly discarding all expired data can turn a short DNS infrastructure outage into a complete service outage—even when the previously cached address is still correct.

RFC 8767 defines a mechanism commonly called serve-stale. Under the conditions described in the standard, a recursive resolver may use expired DNS data when it cannot refresh that information from authoritative servers. It can return the stale answer with a positive TTL while continuing to attempt refresh in the background.

Serve-stale is a resilience mechanism, not a way to ignore TTLs indefinitely. It balances two risks: serving data that may no longer be current and failing to resolve a name when authoritative infrastructure is temporarily unavailable. A resolver's configured stale-data policy determines how long expired information may remain available.

For a stable website address, a short period of stale service during a nameserver outage may be better than no answer at all. For a rapidly changing record, a stale answer could direct users to an obsolete server. Resolver operators must consider the application and the consequences of outdated data.

Serve-stale also explains why two resolvers may behave differently after a TTL expires. One may fail to refresh and return an error; another may serve stale data while retrying. Both can be following their configured policies and the relevant standard.

8. DNS TTL versus browser cache and web cache

People often use the word cache for several unrelated mechanisms. A DNS cache stores name-resolution data. A browser HTTP cache stores web resources such as images, scripts, stylesheets and documents. A content delivery network (CDN) may cache copies of web content at edge locations. These systems have different keys, expiry rules and invalidation mechanisms.

Cache typeWhat it storesTypical control
DNS cacheDNS records and related resolution data.DNS record TTL and resolver policy.
Browser HTTP cacheWeb responses and static assets.HTTP Cache-Control, Expires, validators and browser policy.
CDN or reverse-proxy cacheCopies of content served near users.CDN cache rules, origin headers and purge/invalidation tools.
Application cacheApp-specific data or responses.Application logic and local storage policy.

Changing a DNS record does not automatically clear a browser's cached JavaScript file. Purging a CDN does not necessarily flush the ISP's DNS resolver. Clearing browser history may not clear the operating system's DNS cache. A correct troubleshooting process identifies which layer is actually stale.

For example, if a domain resolves to the new server but the browser still displays an old logo, the issue may be an HTTP or CDN cache rather than DNS. If the browser cannot connect and different resolvers return different IP addresses, DNS caching is a stronger suspect.

9. Why DNS changes do not update everywhere at once

Suppose a website owner plans to move a domain from one hosting provider to another. The owner changes the A and AAAA records at the authoritative DNS provider. Some users reach the new host quickly; others continue reaching the old host.

Several reasons can explain this:

  • Existing positive cache entries: a recursive resolver may still hold the previous address until its TTL expires.
  • Different query times: resolvers queried the old answer at different moments, so their expiry times are not identical.
  • Different record types: A and AAAA records may have different values and TTLs. Some clients prefer IPv6 while others use IPv4.
  • CNAME chains: an alias and its target may each have separate cache lifetimes.
  • Negative cache entries: a resolver that previously received NXDOMAIN may continue returning it temporarily after a record is created.
  • Resolver policies: providers may enforce TTL floors, caps or stale-answer behaviour.
  • Delegation changes: changing authoritative name servers can involve parent-zone delegation and glue information, which are separate from ordinary host records.

A useful migration strategy is to plan ahead. If a record's TTL is currently one day, lowering it five minutes before a move does not instantly shorten the lifetime of answers already cached with the old one-day TTL. Reduce the TTL sufficiently in advance, wait for the previous longer cache window to pass, then make the change during a controlled period.

After the move, verify A, AAAA, CNAME and any service-related records from multiple independent resolvers. Keep the old server available for an overlap period where possible. Restore a longer TTL after the new destination is stable. The exact schedule depends on the current TTLs and the operational risk.

10. How to inspect DNS TTL values

You can inspect DNS answers with command-line tools. The examples below are illustrative; the command options and output format can vary by operating system and tool version.

Using dig

dig example.com A
dig example.com AAAA
dig example.com MX
dig example.com A +noall +answer
dig @1.1.1.1 example.com A +noall +answer
dig @8.8.8.8 example.com A +noall +answer

The answer section commonly displays the remaining TTL next to the record class and type. Querying two different resolvers can show whether they currently hold different answers or different remaining TTL values.

Using nslookup

nslookup example.com
nslookup -type=AAAA example.com
nslookup -type=MX example.com

nslookup is widely available, but its output does not always make TTL inspection as straightforward as dig. On Windows, PowerShell's Resolve-DnsName can also query record types and selected servers:

Resolve-DnsName example.com -Type A
Resolve-DnsName example.com -Type AAAA
Resolve-DnsName example.com -Server 1.1.1.1

To check an authoritative server directly, first identify the domain's authoritative name servers, then query the relevant server. This helps separate authoritative data from what a recursive resolver has cached. Be careful to compare the same name, record type and DNS view; split-horizon DNS can intentionally return different answers to different networks.

11. How to troubleshoot a DNS cache problem

Start by describing the symptom precisely. Is the domain not resolving, resolving to an old IP address, returning NXDOMAIN, returning SERVFAIL, or resolving correctly while the website itself shows old content? These are different problems.

  1. Check the authoritative answer. Query the authoritative name server to see what it currently publishes. Confirm the record name, type, value and TTL.
  2. Compare recursive resolvers. Ask the resolver configured on the affected network and one or two independent resolvers. Different answers can indicate cache differences, DNS views or propagation of a delegation change.
  3. Check both A and AAAA. A browser may use IPv6 when available. An incorrect AAAA record can create a problem even when the IPv4 A record looks correct.
  4. Check aliases and dependencies. Follow CNAME targets and relevant service records. The stale information may be in a target record rather than the first name.
  5. Look for negative caching. If a name was recently created, a previously cached NXDOMAIN or NODATA response may still be active.
  6. Inspect DNSSEC validation. A broken DS/DNSKEY relationship or expired signature can produce validation failures. Do not disable validation as a first response; identify the actual error.
  7. Check the local device and browser path. Determine which resolver the application is using and whether a local cache or secure-DNS setting changes that path.
  8. Separate DNS from HTTP and CDN caching. If the domain resolves to the expected destination, inspect web cache headers, CDN rules, application deployment and origin behaviour.

On Windows, an administrator can flush the Windows DNS client cache using:

ipconfig /flushdns

On macOS, the cache-flush command depends on the operating-system version and service configuration. On Linux, behaviour depends on whether a local caching service such as systemd-resolved, dnsmasq or another resolver is active. Restarting a particular local resolver may clear its cache, but do not run commands blindly on production servers. Identify the service first and consult its documentation.

Flushing a local cache only affects that local cache. It does not erase entries held by an ISP resolver, public recursive resolver, enterprise DNS service, browser-specific resolver or CDN. If the stale answer is upstream, waiting for its TTL or using the provider's supported cache-management process may be necessary.

12. Choosing a TTL: speed, control and operational risk

There is no single best TTL for every record. A short TTL can make planned changes visible sooner after old entries expire, but it increases the frequency of refresh queries. A long TTL can reduce repeated lookups and provide more stable caching, but it can make changes take longer to be reflected by caches that already hold an older answer.

Consider the purpose of the record:

  • Stable website address: a longer TTL may be appropriate when the destination rarely changes and the operator values cache efficiency.
  • Planned migration: a temporarily reduced TTL can help, provided it is lowered early enough for old cached values to expire before the cutover.
  • Failover design: TTL is only one part of failover. Health checks, load balancers, routing, application retries and resolver behaviour also affect recovery time.
  • Mail records: MX and related records should be managed carefully because mail delivery depends on more than a single web address.
  • Dynamic services: frequent changes may justify shorter TTLs, but the authoritative DNS provider's limits and query capacity must be considered.

Do not promise users that a 60-second TTL guarantees a global update in 60 seconds. A client may have cached the previous value before the TTL was reduced; an intermediate resolver may enforce a minimum; a negative answer may have its own TTL; and some resolvers may serve stale data during upstream failures.

TTL is a cache-control input, not a global synchronisation command.

13. DNS caching, privacy and security

Caching changes how often a resolver receives a query, but it does not automatically make DNS private. A recursive resolver that receives a query can generally observe the name being requested. Encrypted DNS transports such as DNS over HTTPS (DoH) and DNS over TLS (DoT) protect the connection between a client and its chosen resolver, but the resolver still processes the query.

DNSSEC protects the authenticity and integrity of signed DNS data; it does not encrypt queries. These technologies address different layers. DNS cache poisoning defences, resolver hardening, DNSSEC validation, encrypted transport, access controls and careful key management can complement each other.

Cache contents can also be security-sensitive. A shared resolver must isolate clients appropriately and implement DNS protocol rules correctly. Incorrect cache-key handling, stale data, poisoning vulnerabilities or misconfigured split-horizon policies can cause unexpected answers. Administrators should keep resolver software updated and monitor for unusual query patterns or validation errors.

Negative caching has security implications too. It can reduce repeated upstream work during attacks or outages, but a cached negative answer can also delay visibility of a newly created record. Operational teams should understand their resolver's failure caching and logging behaviour rather than treating every repeated failure as proof that authoritative DNS is still broken.

14. Common DNS caching myths

Myth: Changing a record updates every resolver immediately.

False. Resolvers may continue using previously cached data until its remaining TTL expires. DNS does not generally push a purge to every independent cache.

Myth: A TTL is the time a domain takes to propagate.

Not exactly. TTL is the permitted cache lifetime for a record. Different caches have different expiry times, and negative answers and resolver policies also matter.

Myth: Flushing browser history clears all DNS caches.

False. Browser history, HTTP cache, local DNS cache and recursive resolver caches are separate systems.

Myth: A short TTL always makes a website faster to update.

It can shorten the cache window for new queries after the lower TTL is published and old entries expire. It does not retroactively shorten existing cached entries.

Myth: NXDOMAIN means the domain owner has not created the record.

It may mean that, but a resolver could also be returning a cached NXDOMAIN from before the record was created. Check the authoritative server and negative TTL.

Myth: Expired DNS data can never be used.

RFC 8767 defines serve-stale behaviour that allows resolvers to use expired data in specified circumstances when authoritative refresh is not possible. Resolver policy matters.

15. A practical checklist for website owners and administrators

  • List every DNS record that matters to the service: A, AAAA, CNAME, MX, TXT, SRV and relevant delegation records.
  • Record the current TTLs before making changes.
  • Lower TTLs sufficiently in advance of a planned migration; do not expect an immediate effect.
  • Verify both IPv4 and IPv6 answers.
  • Check authoritative data separately from recursive answers.
  • Understand negative caching before testing newly created names.
  • Confirm DNSSEC signing and DS data if the zone is signed.
  • Document the DNS provider's TTL floors, caps, cache purge tools and failover behaviour.
  • Test from multiple networks and resolvers without assuming every resolver must return the same answer at the same moment.
  • Keep the old service available during a migration where feasible.
  • Separate DNS symptoms from browser, CDN, reverse-proxy and application caches.
  • Monitor authoritative server health and resolver validation errors.

For home users, the practical approach is simpler: compare the result from another network or resolver, restart the local connection only when appropriate, and avoid changing advanced router DNS settings unless you understand the effect. If only one device has the issue, investigate its local resolver path. If many devices on the same network have the same issue, inspect the router or upstream DNS service.

16. The bigger picture: caching is a balance, not a bug

DNS caching is sometimes blamed when a change appears slow, but caching is a core part of how the DNS scales. It prevents every device from repeatedly asking the authoritative hierarchy for the same records. It improves lookup performance, reduces load and can support resilience.

The same mechanism creates a temporary gap between an authoritative change and what a particular client sees. Positive TTLs, negative caching, failure caching, local caches and serve-stale policies each contribute to the result. Once these mechanisms are understood, DNS behaviour becomes much easier to diagnose.

The most useful question is not simply, “Why has DNS not updated?” It is: “Which resolver answered, what exact record type was queried, what answer did the authoritative server publish, and how much cache lifetime remains?” That turns a vague waiting problem into a sequence of testable checks.

Standards and further reading

Standards describe protocol requirements; individual resolver products may expose additional settings and operational policies. Consult the current documentation for the resolver and authoritative DNS provider you operate.

Frequently asked questions

1. What is DNS caching in simple terms?

DNS caching is the temporary storage of DNS answers so a resolver or device can reuse them instead of repeating the lookup. It usually reduces lookup time and unnecessary DNS traffic.

2. What does TTL mean in DNS?

TTL means Time to Live. It is the number of seconds a DNS record may be reused from a cache before the cache should obtain fresh information. The remaining TTL generally decreases as the record stays cached.

3. How long does DNS propagation take?

There is no single global propagation timer. Existing positive or negative cache entries can remain until their applicable TTL expires, and resolver policies, delegation changes and stale-answer behaviour can affect what different users see.

4. Why does NXDOMAIN continue after I create a DNS record?

A resolver may have cached an earlier NXDOMAIN response. Negative caching is defined by RFC 2308, and the negative TTL is derived from the authoritative zone's SOA information. Check the authoritative answer and wait for the cached negative entry to expire.

5. What is the difference between NXDOMAIN and NODATA?

NXDOMAIN means the queried name does not exist. NODATA means the name exists but does not have the requested record type, such as an AAAA record. Their negative-cache matching rules are different.

6. Does flushing DNS clear every DNS cache?

No. Flushing a local device cache does not clear caches held by a router, ISP, public recursive resolver, browser-specific resolver or other network service. Each cache has its own lifecycle.

7. Can DNS resolvers use expired records?

Under the serve-stale mechanism in RFC 8767, a recursive resolver may use expired data in specified circumstances when it cannot refresh information from authoritative servers. The resolver's configuration controls the operational policy.

8. Does a lower DNS TTL make changes instant?

No. Lowering a TTL does not retroactively shorten the lifetime of entries already cached with the old TTL. It can help future cache entries expire sooner after the previous cache window has passed.

9. What is negative caching in DNS?

Negative caching stores answers that say a name or requested record does not exist, and modern standards also require caching resolution failures. It reduces repeated upstream queries but can temporarily delay recognition of newly created records.

10. How can I check the DNS TTL for a domain?

Use a DNS query tool such as dig and inspect the answer section. Commands such as dig example.com A +noall +answer display the record and its remaining TTL when the resolver returns an answer.