A DNS record's TTL (time to live) is the number of seconds a resolver may keep a cached copy before asking again. It's the single setting that decides whether a DNS change takes five minutes or a day. I've covered why changes seem slow in DNS propagation explained. This post is the practical companion: how to see the TTL that's really in effect, which values to use, and exactly when to change them around a migration.
The TTL is the second column in dig output:
dig example.com A
example.com. 1800 IN A 192.0.2.10
There's a catch. If you ask your normal resolver, that number is the time remaining in its cache, and it counts down each time you repeat the query. To see the value you actually configured, ask one of the domain's authoritative name servers directly:
dig NS example.com +short
dig @ns1.example.net example.com A +norecurse
The authoritative server always reports the full configured TTL. If the two numbers differ, the first is simply a cache partway through its countdown.
There's no official "correct" TTL. It's a trade: a long TTL means fewer queries and more resilience if your DNS provider has a blip, and a short one means faster changes. Some reasonable starting points:
If your records are proxied through a CDN, the TTL may not be yours to set. Cloudflare, for example, fixes proxied records at "Auto", which is 300 seconds, because the address visitors see belongs to Cloudflare, not your server.
Three other timers affect how long changes take, and people forget them.
Name server delegation. The NS records that point a domain at its DNS provider live in the parent zone, run by the registry. For .com, they're served with a TTL of 172800 seconds, which is two days:
dig NS example.com @a.gtld-servers.net +norecurse
Look at the TTL in the authority section. You can't lower it, which is why moving to a new DNS provider has a slow tail that editing a record doesn't.
Negative caching. When a name doesn't exist, resolvers cache that too. RFC 2308 sets the negative cache time as the smaller of the SOA record's own TTL and the last field of the SOA record (historically called "minimum"). Check yours:
dig SOA example.com +short
ns1.example.net. hostmaster.example.com. 2026100401 7200 3600 1209600 3600
The final 3600 means a lookup for a missing name is remembered for up to an hour. RFC 2308 suggests one to three hours as a sensible default. That's why creating a record after someone has already looked it up can seem slow.
Resolver limits. RFC 2181 says the TTL is a maximum, not a promise, and resolvers may cap it. BIND caps cached answers at one week by default and negative answers at three hours. Unbound caps at one day by default. So a TTL of 604800 or more often gets shortened anyway. A few resolvers also keep serving stale records if your authoritative servers go unreachable (RFC 8767 describes this), which is another reason not to shut old infrastructure down too early.
The key fact: the TTL that matters on the day of the change is the one resolvers cached before it. Lowering the TTL and changing the record in one sitting achieves almost nothing. Here's the schedule I use, assuming the current TTL is 86400 (one day):
www as well as the bare domain.If the old TTL was 3600, the same plan compresses to a few hours. If you don't know the old TTL, look it up now, before you touch anything.
For moves where DNS is only one part of the job, see the full checklist in how to move a website without downtime.
www is a CNAME to the bare domain, the TTL on both records counts.For a planned change, 300 is plenty. Lower values mainly add query load. Some providers set a floor anyway, commonly 60 or 30 seconds.
Slightly more DNS lookups happen, and a visitor whose cached entry has expired waits one extra round trip to the resolver. For most sites it isn't noticeable, but there's also no benefit to keeping a short TTL when nothing's changing.
You're querying a caching resolver, which reports the time left before its copy expires. Query the authoritative name server with +norecurse to see the configured value.
It's allowed by the standard and means "don't cache". In practice many resolvers apply a minimum anyway, and many DNS providers won't accept zero. Don't rely on it.
0 comments
No comments yet. Be the first.