What is TTL (Time-To-Live) and how does it work?

Every domain connected to a website, email or another service has DNS records, which are settings that tell the Internet where your website and email are located.

TTL (Time to Live) is a number on each record that says how long other systems can remember that record before they check for a new one. It’s measured in seconds.

When someone visits your site, their Internet provider looks up your DNS record and saves a copy, so it doesn't have to ask again for the next visitor. TTL sets how long that copy is kept. Set it to 3600, for example, and that copy lasts an hour before the provider asks again and gets the current record.

TTL matters most when you change a record. Say you move your site to a new host and update its DNS record. Anyone whose provider saved a copy of the old record keeps going to the old address until that copy expires. The TTL you set decides how long that takes. With a short TTL, such as 300 seconds (5 minutes), changes reach visitors quickly, but servers have to look up your record more often. With a long TTL, such as 86400 seconds (24 hours), there are fewer lookups, but a change can take up to a day to show for everyone.

If you know a change is coming, lower the TTL first and wait for the old value to run out. After you make the change, old copies then expire within minutes instead of hours.

In short, use a short TTL for records you expect to change, and a longer one for records that stay the same.


DNS TTL vs. IP packet TTL

This guide explains how DNS TTL works in more detail, which values you will see, and the pros and cons of using different TTL values.

Before we dig into DNS TTL, it’s worth knowing that two different networking mechanisms share the name Time to Live, even though they do very different jobs.


IP packet TTL

IP packet TTL determines the maximum number of hops an IP packet can pass through before it is discarded. A hop is one step of the packet's journey from one router to the next.

Each time a router forwards the packet, its TTL value decreases by one. When the value reaches zero, the packet is discarded. This prevents data packets from circulating endlessly across the internet due to routing loops. Typical starting values are 64 or 128 hops.

DNS TTL

DNS TTL sets how long a DNS resolver can cache a record before it checks for a fresh copy.

For example, if a DNS record has a TTL of 1800 seconds, a resolver can keep and reuse this information for 30 minutes. This helps reduce unnecessary DNS queries and makes website access faster. Typical DNS TTL values range from a few minutes to 24 hours or longer.


The two side by side:

IP TTL vs DNS TTL
ParameterIP packet TTLDNS TTL
PurposePrevents packet forwarding loopsControls DNS cache duration
Applies toIP packetsDNS records
UnitHopsSeconds
Decreases withEach router hopElapsed time
When it expiresPacket is discardedCached record expires


In short: IP TTL is a hop counter for data packets, while DNS TTL is a cache timer for DNS records.


DNS TTL

DNS TTL is a value set on a DNS record, measured in seconds. It tells resolvers and browsers how long to cache the record's value (for example, an IP address) before checking for updates. As a result, it also determines how long it takes for record updates to reach users.

A DNS resolver is a server that looks up domain names and finds the corresponding records that connect the domain with a respective server (a web server, a mail server, etc.). Instead of performing a new lookup every time, a DNS resolver can temporarily store previously retrieved DNS information. This process is called DNS caching.

The TTL value determines how long that cached information remains valid. It creates a balance between performance and how quickly DNS changes become visible.

When a DNS record has a longer TTL:

  • DNS resolvers can reuse cached information for longer.

  • Fewer DNS queries are sent to authoritative DNS servers (the servers that hold the official DNS records for the domain), which reduces their load.

  • DNS lookups are generally faster because cached data is more likely to be available.

  • Changes to DNS records may take longer to become visible to users who still have the old data cached.

When a DNS record has a shorter TTL:

  • DNS resolvers refresh cached information more often.

  • DNS changes may become visible sooner after the previously cached data expires.

  • More DNS queries are sent to authoritative DNS servers, which increases their load.


Default TTL values for DNS records

DNS providers may use different default TTL values depending on the record type and their configuration.

For example, Namecheap uses the following default settings:

  • Standard DNS records: 1800 seconds (30 minutes).

  • ALIAS records: TTL values between 60 and 300 seconds (1-5 minutes) are supported. The default value is 300 seconds.

Keep in mind that TTL values are configured separately for each DNS record. For example, changing the TTL of a CNAME record doesn’t change the TTL of the DNS record it’s pointed to. Each record has its own caching period.

You can configure the TTL in the Advanced DNS tab (Domain List > Manage > Advanced DNS) if the domain uses Namecheap BasicDNS, FreeDNS, or PremiumDNS. By default, TTL is set to Automatic (1800 seconds) for all records except ALIAS. You can change the TTL manually by selecting a different value. In Advanced DNS, TTL is indicated in minutes.

It’s possible to create host records on our BasicDNS/PremiumDNS/FreeDNS nameservers with the following TTL values: 1 minute, 5 minutes, 20 minutes, 30 minutes, 60 minutes, and Automatic - 1800 seconds (except for ALIAS).


How DNS TTL works

Now that we know what TTL means, let’s look at how it works when someone visits a website. Imagine someone types example.com into their browser. Here’s what happens:

  1. A user requests a domain. When a user enters the domain in the browser address bar, the browser needs to find the IP address associated with the domain.

  2. The resolver checks its cache. It looks for a previously saved DNS record that hasn't expired.

  3. The resolver performs a DNS lookup if necessary. If there’s no valid cached record, the resolver contacts the relevant DNS servers to find the authoritative answer.

  4. The resolver caches the response. Once it receives the DNS record, it stores the information for the period specified by the record's TTL. For example, a TTL of 1800 seconds means that the information is stored for 30 minutes.

  5. Subsequent requests use the cached record. During the remaining TTL period, the resolver can return the stored IP address without performing another lookup.

  6. The TTL expires. Once the caching period ends, the resolver must perform a new lookup to obtain fresh information the next time the domain is requested.

It’s important to note that TTL does not control DNS propagation. TTL does not push DNS updates to resolvers. It only determines how long cached records remain valid. As a result, if a record was updated, resolvers that already cached the old version may keep returning it until their cached copy expires.

Once the TTL expires, resolvers don't contact the authoritative DNS server on their own. They perform a new lookup only when there is another request for that DNS information. Different resolvers may also have cached the old records at different times.

Additionally, factors such as operating-system caching, browser caching, and ISP-specific behavior can affect when users see the updated settings.



What is a CDN TTL?

When working with websites, you may also encounter another type of TTL called CDN TTL. Although it shares the same name, CDN TTL serves a different purpose from DNS TTL.

A CDN (Content Delivery Network) is a network of servers distributed across different geographical locations. Instead of making every website visitor download content directly from the main web server, a CDN delivers cached content from a server located closer to the visitor.

For example, if your website's main server is in the United States and someone visits it from Europe, a CDN can serve images, scripts, and other content from a nearby European server. This helps websites load faster and reduces the amount of traffic handled by the main server.



DNS TTL vs. CDN TTL

Although both settings control caching, they apply to different types of information:

  • DNS TTL determines how long DNS resolvers cache information about a domain, such as its IP address.

  • CDN TTL determines how long CDN servers store copies of website content, such as images, CSS files, JavaScript, and other resources, before checking the origin server for updates.

Think of DNS TTL as remembering a website's address, while CDN TTL is like keeping a local copy of the website's content. Both mechanisms help improve website performance, but they work at different levels.

Note: CDN caching duration may be controlled by HTTP Cache-Control headers, CDN configuration rules, or a combination of both. As a result, different website resources can have different caching periods.


Understanding SOA record fields

The SOA (Start of Authority) record contains important information about a DNS zone, including details about its primary DNS server and the timings used to synchronize DNS information between servers.

The following parameters are especially important when talking about DNS timing:

  1. SOA TTL: Specifies how long the SOA record itself can be cached by DNS resolvers before it needs to be refreshed.

  2. Refresh: Defines how often a secondary DNS server should check the primary one for updates to the DNS zone.

  3. Retry: Indicates how long a secondary DNS server waits before retrying a zone refresh if the previous attempt failed.

  4. Expire: Defines how long a secondary DNS server can continue serving its DNS zone as authoritative if it can’t successfully synchronize with the primary server. This ensures outdated DNS records are not served indefinitely.

  5. Negative caching TTL (NX TTL): Defines how long DNS resolvers can cache negative responses, such as NXDOMAIN, which indicates that a requested domain does not exist. For example, when you request a website that doesn't exist, your browser shows an error such as "This site can't be reached.” In the SOA record, this value is stored in the Minimum field.

Refresh, Retry, and Expire are synchronization timers, not DNS record TTL values. The Minimum field is also not a general-purpose TTL setting. It’s used to calculate the caching period for negative DNS responses.

These settings help with syncing zone information and managing situations where communication between primary and secondary nameservers fails.


Why is DNS TTL important?

Choosing an appropriate TTL value helps you find the right balance between DNS performance and flexibility.

More efficient caching and better performance

When a resolver already has a valid DNS record in its cache, it can return the information without performing a new lookup. A suitable TTL reduces unnecessary queries to authoritative DNS servers, shortens DNS lookup time, and helps users reach websites faster.

Greater flexibility when updating DNS records

Shorter TTL values are useful when you expect to change DNS records. For example, if you’re planning to move your website to a different hosting provider, lowering the TTL in advance can reduce the time resolvers continue using the old IP address after the change.

Lowering the TTL doesn’t clear records that are already cached, so do it early. Set the lower TTL at least one full period of the old TTL before you make the change. For example, if the old TTL is 24 hours, lower it at least 24 hours in advance. Once the change is complete and working, you can raise the TTL again to benefit from longer caching.

DNS TTL values determine how long resolvers cache records, and they do not guarantee immediate global propagation. Existing caches, resolver behavior, and client-side caching may delay changes.

Updated
Viewed
22488 times

Need help? We're always here for you.

notmyip