Learn
What Is a Web Server? Web Server vs Application Server
A web server accepts HTTP connections, terminates TLS, serves static files from disk and forwards dynamic requests to ...
Time to live (TTL) is a limit attached to data that sets how long, or how far, it may be cached or forwarded before it must be discarded or refreshed. DNS records and HTTP caches count TTL in seconds. IP packets count it in router hops, capped at 255 by an 8-bit header field.
This guide answers what is TTL for DNS, CDN caches, IP and databases. It then gives recommended values, a cutover timeline with the arithmetic, and a failure-mode checklist.
As of 2026, under RFC 1035 a DNS TTL is a 32-bit count of seconds. A record published with TTL 300 may be cached by recursive resolvers for at most five minutes before they must query the authoritative server again. That cache lifetime, not a propagation process, sets how fast a DNS change reaches users.
Every TTL has three properties to pin down before you tune it: the unit (hops or seconds), who sets the starting value, and who enforces expiry. Most production confusion comes from assuming that whoever publishes a TTL also controls when the data disappears. It rarely does.
In IPv4, every router that forwards a packet decrements TTL by at least one. At zero, the router discards the packet and usually returns ICMP Time Exceeded (type 11). IPv6 renamed the field Hop Limit and kept the same semantics. The mechanism exists to kill routing loops. Traceroute exploits it by sending probes with TTL 1, 2, 3 and so on, then recording which router answers each one.
Initial values reveal operating-system defaults. Linux and macOS start at 64, Windows at 128, and many routers and appliances at 255. A ping reply showing TTL 52 most likely came from a Linux host 12 hops away. Tunnels complicate the picture: GRE and MPLS can copy or reset the inner TTL, so some paths look shorter in traceroute than they really are.
DNS TTL is the number of seconds a recursive resolver may cache a record after fetching it from the authoritative server. The resolver counts down from the published value and returns the remaining seconds to clients. Two users querying the same resolver a minute apart therefore see TTLs 60 seconds apart. At zero, the next query triggers a fresh lookup.
TTL applies per record set: RFC 2181 requires every record in an RRset to share one TTL. Negative answers are cached too. Under RFC 2308, an NXDOMAIN is cached for the lesser of the SOA record's TTL and its MINIMUM field.
Resolver policy then bends the published value:
Below the resolver, clients add their own layers. Operating-system stub caches and the JVM address cache (30 seconds by default in current releases) both sit there. So do HTTP connection pools, which keep sockets open to an old IP regardless of any DNS TTL.
For HTTP, TTL is the freshness lifetime defined in RFC 9111. A shared cache takes it from s-maxage first, then max-age, then Expires. If none of these is present, caches may apply heuristic freshness, commonly 10% of the time since Last-Modified.
The Age header records how long an object has already sat in upstream caches, and downstream caches subtract it. A browser that receives max-age=3600 with Age: 3000 treats the object as fresh for only 600 more seconds.
CDNs split this into an edge TTL (how long the CDN keeps the object) and a browser TTL (what it forwards in Cache-Control), and most let you override origin headers. The stale-while-revalidate and stale-if-error directives (RFC 5861) extend serving past expiry. They deliberately trade freshness for origin protection.
Long edge TTLs are only safe when you can evict on demand. On BlazingCDN, purge, cache warm-up through the API and origin shield are included on every plan, and custom cache rules are set up together with an engineer. A long edge TTL therefore does not trap a bad deploy.
Key-value stores and databases attach a TTL to an item when it is written. Redis expires keys lazily on access and through an active sampling sweep, so memory is reclaimed gradually.
DynamoDB removes expired items in a background process that vendor documentation says can take days. Until then, expired items still appear in reads, so queries must filter on the expiry attribute. Cassandra turns expired cells into tombstones that persist for gc_grace_seconds (ten days by default) and can slow reads.
TTL suits sessions, rate-limit counters, temporary tokens and presence data. It fits poorly where deletion must follow audited legal or contractual procedures.
| Layer | Unit | Set by | Enforced by | At expiry |
|---|---|---|---|---|
| IPv4 TTL, IPv6 Hop Limit | Router hops, max 255 | Sending host OS | Each router | Packet discarded, ICMP Time Exceeded |
| DNS | Seconds | Authoritative zone | Recursive resolvers, stub caches | Re-query, or serve stale if allowed |
| HTTP and CDN | Seconds | Origin headers or CDN rules | Edge, shield, browser | Revalidate or refetch |
| Database and key-value store | Seconds or timestamp | Application at write time | Storage engine | Hidden, physically deleted later |
In every layer, the party that sets the TTL is not the party that enforces it, so the effective TTL must be measured rather than read from config.
TTL vs. Hop Limit: these are the same field under two names. IPv4 calls it TTL and IPv6 calls it Hop Limit, and both count hops, not time.
DNS TTL vs. propagation: DNS has no push mechanism. "Propagation" is simply the time it takes cached copies to expire, bounded by the old TTL plus any resolver overrides.
Cache TTL vs. max-age: max-age is one header that sets a TTL. A CDN may override it with s-maxage, an edge rule or a forced minimum.
The values below are this blog's suggested starting points, not universal rules. Tune them against your own change frequency and query budget.
| Record or object | Steady state | Change window | Reason |
|---|---|---|---|
| A and AAAA for apex and www | 3,600 s | 60 to 300 s | Balances resolver load and agility |
| Health-checked failover records | 30 to 60 s | 30 s | Failover speed is bounded by TTL |
| CNAME to a CDN hostname | 3,600 s | 300 s | The CDN's own records handle steering |
| MX and TXT (SPF, DKIM) | 3,600 to 86,400 s | 300 s | Rarely changes; mail retries tolerate delay |
| NS and delegation | 86,400 s | Plan days ahead | The parent zone's TTL (172,800 s in .com) governs cached delegation |
| SOA MINIMUM (negative caching) | 300 to 3,600 s | 60 s | Avoids hours of NXDOMAIN for new names |
| Fingerprinted static assets, VOD segments | max-age=31536000, immutable | Not needed | The URL changes when the content does |
| HTML documents | s-maxage 60 to 300, max-age 0 | Purge on deploy | Freshness with origin protection |
| Live HLS or DASH playlists | About half the segment duration | Not needed | A stale playlist stalls players |
| API responses | 0 to 60 s plus stale-while-revalidate | Per endpoint | Correctness varies by route |
Short TTLs belong only on names and objects that change without notice; anything addressable by a versioned name should carry the longest TTL its layer allows.
A resolver holding a popular record refreshes it about 86,400 ÷ TTL times a day. At TTL 3,600 that is 24 upstream queries per resolver per day. At TTL 60 it is 1,440, a 60x increase.
With 50,000 distinct resolvers asking for one hostname, authoritative load rises from 1.2 million to 72 million queries a day, which matters on DNS providers that bill per million queries. Users pay too: every expiry forces one uncached lookup, typically 20 to 100 ms, sometimes more.
Lowering a TTL only affects copies fetched after the change. Records already cached under the old, longer value stay cached until that value runs out. This worked timeline assumes a current TTL of 86,400 seconds:
A useful rule of thumb: full cutover time equals the new TTL, plus the longest resolver override, plus the longest client connection lifetime. The last term is usually the largest, and DNS cannot shorten it.
The cause is usually a TTL lowered too late, or clients that ignore DNS entirely, such as pooled HTTP/2 connections or long-running JVM processes. To confirm, check connection age and client IPs in the old origin's logs. If requests arrive on connections older than the cutover, DNS is not the problem.
Someone queried the name before it existed, and resolvers cached the negative answer under a large SOA MINIMUM. To confirm, read the SOA record. A MINIMUM of 86,400 explains a day of failures.
TTLs stack when an edge or shield resets the Age header instead of passing it through, so each tier restarts the clock. Stacking also happens when stale-if-error is quietly masking an origin outage. To confirm, compare Age and the cache-status header across repeated requests, and check origin error rates during the same window.
A routing loop exhausts the TTL, or a tunnel resets it. To confirm, look for ICMP type 11 in a packet capture and for the same hop pair repeating in traceroute output.
Physical deletion lags logical expiry. To confirm, add an expiry-timestamp filter to the query and see whether the phantom rows vanish.
Verify on your own stack by running dig against a public resolver twice, a minute apart, and confirming the TTL column dropped by about 60. Then dump edge response headers and read Cache-Control, Age and the cache-status header together.
TTL means time to live, a limit on how long or how far data may persist before it is discarded or refreshed. In IP packets it counts router hops, up to 255. In DNS records and HTTP caches it counts seconds. The unit and the enforcing system differ by layer, so always identify which layer a TTL value belongs to.
For most production A and AAAA records, 3,600 seconds is a sound default. Use 30 to 60 seconds only on health-checked failover records, and drop to 60 to 300 seconds temporarily before a planned migration. Very short TTLs multiply authoritative query volume (TTL 60 means 60 times the refreshes of TTL 3,600) and add uncached lookups for users.
Lowering DNS TTL speeds up future changes, not the current one. Resolvers that cached a record under the old TTL keep it until that value expires, so the reduction must happen at least one full old TTL before the change. Resolver minimum floors, serve-stale policies and long-lived client connections can still extend the transition.
Those numbers are the remaining IP TTL in the reply packet, which reflects the sender's initial value minus the hops travelled. Linux and macOS start at 64, Windows at 128 and many network devices at 255. A reply showing TTL 116 most likely came from a Windows host about 12 router hops away.
No. CDN cache TTL controls how long an edge keeps an object, using Cache-Control headers or CDN rules. DNS TTL controls how long resolvers cache the address of the CDN hostname. The two are independent, so a fast DNS failover does nothing for stale cached content, and a purge does nothing for a stale DNS answer.
This week, export every record in your zones and flag any TTL above 3,600 on names that might change, along with any SOA MINIMUM above 3,600. Then sample 20 high-traffic URLs at the edge and record Cache-Control, Age and cache status for each. Mismatches between intended and observed TTLs are your failure modes in waiting, and fixing them costs nothing.
If the audit shows your heavy static traffic needs long edge TTLs with reliable purge, the BlazingCDN Anycast CDN page describes pull caching with origin shield, request coalescing and API purge included on every plan.
Heavy traffic.
Light bill.
The CDN for video and large traffic
Learn
A web server accepts HTTP connections, terminates TLS, serves static files from disk and forwards dynamic requests to ...
Learn
What is a proxy server? A proxy server is an intermediary that accepts a client's request, applies policy, and then ...
Learn
A reverse proxy is a server that sits in front of one or more origin servers, accepts client connections on their ...
Learn
A cache is a small, fast storage layer that keeps copies of data close to where they are read, so repeat requests skip ...