What is TTL?
TTL (Time To Live) is a DNS setting that specifies, in seconds, how long a DNS record should be cached by resolvers, browsers, and other systems before they must request a fresh copy from authoritative nameservers. TTL values balance between fast propagation of DNS changes (low TTL) and reduced server load with better performance (high TTL).How TTL Works
DNS Query Flow with TTL:
1. Client queries resolver for example.com
2. Resolver checks cache - not found
3. Resolver queries authoritative server
4. Server returns: A record 192.0.2.1, TTL 3600
5. Resolver caches for 3600 seconds (1 hour)
6. Subsequent queries served from cache
7. After 3600s, cache expires, cycle repeats
Common TTL Values
| TTL (seconds) | Duration | Use Case |
|---|---|---|
| 60-300 | 1-5 minutes | During DNS changes, failover |
| 300-900 | 5-15 minutes | Dynamic services |
| 3600 | 1 hour | Standard websites |
| 14400 | 4 hours | Stable records |
| 86400 | 24 hours | Rarely changing records |
TTL in DNS Records
Record Format
example.com. 3600 IN A 192.0.2.1
│
└── TTL in seconds
Different TTLs per Record
; Stable nameservers - high TTL
example.com. 86400 IN NS ns1.example.com.
; Web server - moderate TTL
www.example.com. 3600 IN A 192.0.2.1
; Dynamic content - low TTL
api.example.com. 300 IN A 192.0.2.50
TTL Strategy
Before DNS Changes
Lower TTL ahead of planned changes:
Timeline:
Day -2: Lower TTL from 86400 to 300
Day 0: Make DNS change
Day 0+: Change propagates within 5 minutes
Day +1: Raise TTL back to 86400
Tradeoffs
| Low TTL (60-300) | High TTL (3600+) |
|---|---|
| Fast propagation | Slow propagation |
| More DNS queries | Fewer DNS queries |
| Higher server load | Lower server load |
| Better for failover | Better for stability |
| Higher latency | Lower latency |
TTL and DNS Propagation
TTL directly affects propagation time:
Max propagation time ≈ Highest cached TTL
If TTL = 86400 (24 hours):
- Some users see old IP for up to 24 hours
- Global propagation: up to 24-48 hours
If TTL = 300 (5 minutes):
- Most users see new IP within 5-10 minutes
- Global propagation: under 1 hour
Checking Current TTL
Using dig
dig example.com A
;; ANSWER SECTION:
example.com. 3542 IN A 192.0.2.1
│
└── Remaining TTL (seconds until cache expires)
Using nslookup
nslookup -debug example.com
Best Practices
1. Use appropriate values: Match TTL to record volatility
2. Lower before changes: Reduce TTL 24-48 hours ahead
3. Consider caching layers: CDNs, browsers add delays
4. Balance load vs speed: Don't set unnecessarily low
5. Monitor after changes: Verify propagation complete
6. Document standards: Establish TTL policies
TTL is a fundamental DNS concept that directly impacts how quickly DNS changes take effect across the internet and how much load your nameservers handle.