What TTL (time to live) means
In DNS, TTL (time to live) is the number of seconds a record may be cached before it should be discarded. The field is a 32-bit unsigned integer.
The same three letters also name another field. The MPLS shim header carries an 8-bit TTL alongside a 20-bit label. It is a different field from the 32-bit DNS one.
How DNS TTL controls caching and propagation
A resolver is a server that looks up answers for users. A resolver may keep each answer in its cache, a store of earlier answers, until the record's TTL runs out. Cached data is eventually discarded by a timeout. In a cache the TTL conceptually counts down, while the zone keeps a constant value.
| TTL (seconds) | Time |
|---|---|
| 0 | do not cache |
| 300 | 5 minutes |
| 3600 | 1 hour |
| 14400 | 4 hours |
| 86400 | 1 day |
- TTL 0 means the record can be used only for the transaction in progress and should not be cached.
- The maximum is 2147483647, which is 2^31 - 1.
- A cache may cap the TTL. Implementations may cap a received TTL at an upper bound of their choosing. The TTL is a maximum, not a mandatory time to live. A cache may therefore hold a record for less time than the TTL says.
- "Does not exist" answers are cached too. This is negative caching, the storage of knowledge that something does not exist. Authoritative nameservers (the servers that hold a zone's records) MUST include the zone's SOA (start of authority) record in the authority section of an NXDOMAIN (the name does not exist) or no-data (the name exists but has no record of that type) answer, so the answer can be cached. The negative TTL is the lower of the SOA MINIMUM field and the SOA record's own TTL. It tells resolvers how long they may cache the answer. Negative caching also speeds up negative answers and reduces traffic between resolvers and nameservers.
- Delegation records in a registry zone point to a domain's nameservers and typically include NS records. Registry operators (the organisations that run the registry for a top-level domain) typically set their TTL. EPP is the protocol registrars use to talk to registries. An EPP extension lets the sponsoring client, the registrar that manages the domain, change that TTL.
A cache that already holds a record may keep it until the old TTL runs out. This is why a change is not visible everywhere at once. Lower the TTL before a change, not during it. Before you edit anything, note the current record and its TTL. The propagation checker shows the current state of a record, so you can see which resolvers still return the old answer.
Example: reading a TTL in a record and in a lookup
A record in a zone file. The second field, 3600, is the TTL in seconds (1 hour):
; name TTL class type data
www.example.com. 3600 IN A 192.0.2.10
A lookup from a resolver:
dig +noall +answer www.example.com A
Illustrative output:
www.example.com. 1742 IN A 192.0.2.10
The resolver's answer shows the remaining time, so the number is lower than 3600.
To look up a record's TTL on a live domain, use the DNS lookup tool, which runs live queries. To find the negative-caching value, check the SOA record.
References
- RFC 1035: Domain names - implementation and specification, IETF, sections 6, 6.1.3
- RFC 3443: Time To Live (TTL) Processing in Multi-Protocol Label Switching (MPLS) Networks, IETF, section 2.2
- RFC 2181: Clarifications to the DNS Specification, IETF, section 8
- RFC 2308: Negative Caching of DNS Queries (DNS NCACHE), IETF
- RFC 9803: Extensible Provisioning Protocol (EPP) Mapping for DNS Time-to-Live (TTL) Values, IETF, section 9