TTL (Time To Live) is a numerical value in seconds that determines how long a DNS record is cached by resolvers before a fresh query to the authoritative server is made. It acts as an expiration timer for DNS data across the internet, balancing how quickly infrastructure changes take effect against how much lookup traffic your authoritative nameservers must handle. Every resource record—including A, AAAA, CNAME, MX, and TXT—carries its own TTL setting.
How it works
When a recursive DNS resolver receives a lookup request for a domain, it checks its local memory cache first. If the requested record is present and its countdown timer has not reached zero, the resolver returns the cached answer immediately without contacting your nameservers. Once the TTL expires, the resolver discards the stale entry and performs a fresh recursive query to fetch the current record from the authoritative DNS server.
- Short TTL (60 to 300 seconds): Forces resolvers to check for updates frequently. This is ideal before planned server migrations, IP address swaps, or active failover scenarios where rapid propagation matters most.
- Medium TTL (3600 seconds): Serves as a practical production default for standard web applications, keeping records cached for one hour while still allowing reasonably fast recovery if an unexpected change is needed.
- Long TTL (43200 to 86400 seconds): Keeps records cached for 12 to 24 hours, minimizing query volume on authoritative servers and shaving milliseconds off lookup latency for returning visitors.
Example
In a standard BIND zone file, the TTL sits between the record name and the record class. Below, a web server A record is set to a 300-second TTL ahead of a scheduled migration, while an unchanging MX mail record uses a 24-hour TTL:
$TTL 3600
example.com. 300 IN A 203.0.113.45
example.com. 86400 IN MX 10 mail.example.com.
You can inspect the remaining TTL countdown on a live domain from the command line using dig. Running dig example.com A displays the seconds left before the querying resolver must refresh its cache:
;; ANSWER SECTION:
example.com. 247 IN A 203.0.113.45
What matters when choosing a server or hosting
Different hosting and DNS providers enforce varying rules around TTL customization. When evaluating a managed DNS platform or hosting control panel, check the minimum allowed TTL floor—some budget registrars lock records to a 30-minute or 1-hour minimum, which limits your ability to execute rapid failovers. Look for providers that allow values down to 60 seconds and support automated health-check failovers that dynamically adjust routing without waiting on long cache cycles. Additionally, if your provider charges per million DNS queries, setting overly aggressive TTLs across high-traffic domains can noticeably increase monthly DNS billing.
Common mistakes
- Lowering the TTL at the exact moment of migration: If a record currently has an 86400-second TTL, changing both the IP address and the TTL simultaneously still leaves existing resolvers caching the old IP for up to 24 hours. Lower the TTL at least one full old-TTL cycle in advance.
- Leaving ultra-low TTLs permanently enabled: Keeping a 30- or 60-second TTL indefinitely increases authoritative query load and exposes your site to slower page loads if a resolver must repeatedly traverse the DNS hierarchy.
- Forgetting downstream caching layers: Local operating systems, web browsers, and corporate proxy servers often maintain their own caches that may briefly ignore or clamp very low authoritative TTL values.
FAQ
Does TTL affect website loading speed?
Yes, though mostly on initial connections. A longer TTL increases the likelihood that a visitor's ISP resolver already holds the IP address in cache, avoiding an extra round-trip to your authoritative nameservers before the browser initiates a TCP or TLS handshake.
Can I set a DNS TTL to 0 seconds?
While technically permitted by the DNS specification to signal that a record should never be cached, setting a TTL of 0 is strongly discouraged. Many recursive resolvers ignore zero values and enforce their own minimum floor, while compliant resolvers will hammer your authoritative servers with every single request.
Is DNS TTL the same as IP packet TTL?
No. DNS TTL measures time in seconds for cache expiration, whereas the TTL field in an IPv4 packet header (called Hop Limit in IPv6) counts router hops to prevent packets from looping endlessly across a network.