Tutorials

What is DNS TTL (Time to Live) and What Value Should You Set Before Migration?

What is DNS TTL (Time to Live) Best Values Before Migration - CpanelFree Guide
Written by Blog

Quick Answer: DNS TTL (Time to Live) is a numerical value (measured in seconds) that tells recursive DNS resolvers and ISP caching servers how long to cache a DNS record before requesting fresh data from the authoritative nameserver. 24 to 48 hours before migrating a website, you should lower your A record TTL to 300 seconds (5 minutes) to ensure visitors switch to your new server IP almost instantly upon migration.

How DNS TTL Works Under the Hood

Every DNS record (A, CNAME, MX, TXT) includes a TTL integer. When a user in London queries your website, their local ISP resolver caches your server IP address for the duration of the TTL. If your TTL is set to 86400 (24 hours), the ISP will not check your authoritative nameservers again for a full day.

If you migrate to a new server IP while your TTL is 24 hours, users will continue sending database transactions and eCommerce orders to your obsolete old server for up to 24 hours, resulting in split-brain data loss.

The 3-Phase TTL Migration Strategy

Phase 1: Pre-Migration (24–48 Hours Before Migration)

Access your DNS editor (cPanel Zone Editor, Cloudflare, or Route 53) and lower the TTL on your primary records:

Record Name Standard Production TTL Pre-Migration Target TTL
Root Apex (@) A Record 86,400s (24 Hours) 300s (5 Minutes)
www CNAME / A Record 86,400s (24 Hours) 300s (5 Minutes)

Phase 2: Migration Cutover Day

Once the old 24-hour cache window has elapsed, import your final database dump to the new server and update the A record to your new server IP. Because the TTL is 300 seconds, 99% of global traffic shifts to the new server in under 5 minutes.

Phase 3: Post-Migration Stabilization

After verifying site stability for 48 hours on the new server, restore your TTL back to 86,400 seconds (1 day). This reduces unnecessary DNS query traffic to your nameservers and speeds up browsing for repeat visitors.

Understanding DNS Caching Hierarchies (Browser, OS, ISP, Root)

When a DNS lookup occurs, cached data is stored at 4 distinct hierarchical layers, each governed by TTL rules:

  1. Browser DNS Cache: Google Chrome and Firefox cache IPs in memory for 60 seconds regardless of TTL.
  2. Operating System Resolver Cache: Windows DNS Client and macOS mDNSResponder cache records based on record TTL.
  3. Local Router & ISP Cache: Network gateways and ISP recursive servers cache records up to the full TTL duration.
  4. Authoritative Nameservers: The ultimate source of truth holding your master DNS zone file.

Lowering your TTL to 300s ensures that layers 2 and 3 purge obsolete data almost instantaneously.

Negative TTL and SOA Record Tuning

The Start of Authority (SOA) record contains a Minimum TTL (Negative Caching TTL) value. If an external resolver queries a non-existent subdomain (NXDOMAIN), this setting dictates how long the failure state is cached. Keep this value between 300s and 3600s during active migration windows.

Analyzing Real-World Bandwidth and Server Load Impact of TTL Settings

Setting DNS TTL involves a fundamental engineering trade-off between traffic agility and nameserver infrastructure load:

  • Ultra-Low TTL (60s to 300s): Grants maximum flexibility during server migrations or blue-green failover scenarios. However, it increases DNS query volume to your authoritative nameservers by up to 20x.
  • Standard High TTL (86,400s / 24 Hours): Caches records across ISP resolvers globally, eliminating redundant nameserver queries and providing maximum resilience if your primary nameserver experiences temporary downtime.

DNS TTL for Different Service Records

Record Type Recommended TTL Technical Rationale
Web Server A Record 86,400s (Lower to 300s for migrations) Balances speed with agility
Email MX Record 86,400s (24 Hours) Mail infrastructure changes rarely
Security TXT (SPF/DKIM) 3,600s (1 Hour) Allows rapid mail deliverability updates

Zero-Downtime Web Hosting on CpanelFree

Migrate your websites to CpanelFree with zero downtime. Enjoy high-speed NVMe SSD storage, cPanel control, and unmetered bandwidth at $0 cost forever.

Claim Free Hosting Account

Frequently Asked Questions

Why shouldn’t I leave TTL at 300 seconds permanently?

Low TTL forces client browsers to perform fresh DNS lookups frequently, increasing page load latency and consuming more nameserver lookup bandwidth.

Configuring DNS TTL in Popular Cloud Dashboards (Cloudflare, cPanel, Route 53)

In Cloudflare, setting TTL to Auto enforces a default 300-second (5 minute) TTL on all proxied records. In cPanel Zone Editor and AWS Route 53, you can manually enter numerical second values (e.g. 300 for migration mode or 86400 for standard production).

How long before migrating should I lower my TTL?

Lower your TTL at least 24 to 48 hours prior to changing your server IP to ensure that all worldwide ISP caches have expired their previous long-term entries.

Mastering DNS Time to Live values allows system administrators to balance day-to-day caching efficiency with rapid agility during critical server migrations and emergency disaster recovery scenarios.

Pro Sysadmin Tip: Monitoring Active DNS TTL Countdown

Inspect how many seconds remain on a cached DNS record using the dig command: dig yourdomain.com +nocmd +noall +answer. The second column displays the live remaining TTL countdown in seconds until the next authoritative refresh.

About the author

Blog

DevOps architect and Linux sysadmin specializing in server hardening, OpenLiteSpeed performance optimization, and free cloud hosting infrastructure.

Leave a Comment