DNS TTL - Time To Live

Optimize DNS caching for your performance and flexibility needs.

TTL (Time To Live) is a value in seconds that indicates how long a DNS record can be cached by DNS resolvers. It's a crucial parameter that affects the speed of change propagation and resolution performance.

A short TTL (e.g., 300 seconds) allows rapid changes but increases load on your DNS servers and latency for users. A long TTL (e.g., 86400 seconds) improves performance but delays modification propagation.

Understanding and managing TTL is essential for server migrations, deployments, and incident management. A good balance between stability and flexibility depends on your specific needs.

How TTL Works

TTL controls DNS record caching:

TTL Impact

TTL choice has important consequences:

TTL Strategies

Adopt a TTL strategy suited to your needs:

  1. Standard TTL: For stable records, use 3600-86400 seconds (1-24 hours). Good performance/flexibility balance.
  2. Pre-migration: Before a planned migration, reduce TTL to 300 seconds 24-48h in advance. Caches will be purged when you change IP.
  3. During incident: When a problem requires rapid IP change, you're limited by current TTL. Hence the value of a reasonable TTL.
  4. Post-migration: Once migration is stable, restore a longer TTL to optimize performance.

TTL Configuration Examples

Here are TTL configuration examples:

; Standard TTL (1 hour)
example.com.     3600  IN  A     93.184.216.34

; Long TTL for stable records (24h)
example.com.     86400 IN  NS    ns1.provider.com.
example.com.     86400 IN  MX    10 mail.example.com.

; Short TTL for flexibility (5 min)
api.example.com. 300   IN  A     192.0.2.1

; Check current TTL
$ dig example.com A +noall +answer
example.com.  3542  IN  A  93.184.216.34
# The 3542 indicates seconds remaining before cache expiration

; In a BIND zone, default TTL
$TTL 3600
@ IN SOA ns1.example.com. admin.example.com. (
    2024010101 ; Serial
    7200       ; Refresh
    3600       ; Retry
    1209600    ; Expire
    86400 )    ; Negative TTL

TTL appears after the name and before the class (IN). The dig command shows remaining TTL in the queried resolver's cache. $TTL defines the default TTL for the zone.

TTL Best Practices

Manage your TTLs effectively:

TTL Checklist

  • TTL defined for each record type
  • Reasonable TTL (avoid <60s or >1 week)
  • TTL reduction procedure before migration documented
  • Current TTL verified before urgent changes
  • Propagation monitoring after changes
  • TTL restored after migrations

Frequently Asked Questions - TTL

What TTL should I choose by default?

3600 seconds (1 hour) is a good default. Short enough to propagate changes in a few hours, long enough for good performance. Adjust based on your specific needs.

Why doesn't my DNS change propagate?

Caches keep the old record until TTL expiration. If the old TTL was 86400, wait up to 24h. Some caches also ignore very short TTLs.

Can I force immediate propagation?

No, you don't control external caches. You can clear your own cache (ipconfig /flushdns on Windows) but not those of ISPs or other users.

Is a TTL of 0 possible?

Technically yes, but many resolvers ignore TTL=0 and use a minimum (30-60s). This also generates enormous load on your DNS servers.

Does TTL affect SEO?

Not directly, but a very short TTL can slightly increase DNS resolution latency, which may impact load time. The effect is generally negligible.

How do I see a record's TTL?

Use dig example.com A +noall +answer. The number between the name and IN is the remaining TTL in the queried resolver's cache.

Master TTL for Your DNS

TTL is an important lever to balance performance and flexibility of your DNS infrastructure. A good TTL choice facilitates migrations, improves performance, and gives you control during incidents.

Adopt a consistent TTL strategy, plan reductions before migrations, and monitor propagation of your changes. MoniTao can help verify that your DNS modifications propagate correctly.

Ready to Sleep Soundly?

Start free, no credit card required.