DNS

What is TTL?

TTL stands for Time to Live. TTL is a setting in every DNS record
dictating the length of the time record will be cached by resolving
nameservers and browsers.

What does TTL do?

When you type a domain name into your browser, you’re asking your local resolving nameserver for the domain’s IP address.

When these requests are made, resolving nameservers cache, or store, the information related to the request, allowing the resolving nameserver to deliver results more quickly. When this information isn’t in cache, the resolving nameserver goes through a few more steps to ask the authoritative nameserver for the domain.

Whether the information is received from cache or from the authoritative nameserver, that information will be stored on the resolving nameserver, speeding up resolution time for the next time the request is made.

How does TTL work?

TTL is measured in seconds, not minutes or hours. If setting a 30-minute TTL, for example, you’d translate 30 minutes into seconds for a TTL of 1800.

Low TTLs require the client to query nameservers more frequently, resulting in higher query traffic for your domain name. A high TTL, on the other hand, can cause downtime if you need to switch IPs quickly.

When setting the initial TTL, remember that you’re not locked in. If you plan to change your IP, set the TTL to a low value a few hours before making the change to prevent downtime. You can increase the TTL again once the IP has been changed.

What TTL should I choose?

The recommended TTL will depend on the record type.

A records with failover

A TTL of 180 or lower is recommended for A records with failover. Since the record’s IP will change during an outage of the primary IP, a low TTL will help prevent traffic from going to the downed IP.

A records without failover

A TTL of 1800 to 3600 is recommended for A records without failover. These records are queried very frequently, so a higher TTL will prevent large amounts of queries from being charged. But setting the TTL to no higher than 3600 will allow changes made to the record to take place within a reasonable amount of time.

A records for vanity nameservers

A TTL of 86400 is recommended for A records for vanity nameservers because, while the record will not change, it will be queried when a new query is made for the domains with those vanity nameservers.

CNAME/ANAME/MX/HTTP redirection records

A TTL of 1800 to 3600 is recommended for CNAME/ANAME/MX/HTTP redirection records, with a preference toward a higher TTL. Since these records will be pointing to other records that will be making the changes, changes for these records will be rare. But since these records will be queried fairly frequently, a higher TTL will result in lower query counts.

TXT (SPF)/DMARC/DKIM/CAA records

A TTL of 1800 to 3600 is recommended for TXT (SPF)/DMARC/DKIM/CAA records. If you don’t need to make changes often, opt for the higher TTL, which will be sufficient since these records are primarily used for static verifications.

NS records

A TTL of 86400 is recommended for nameserver records due to this record type’s large volume of queries and low rate of change. These records will be queried each time a record is queried for the domain, so a higher TTL will result in lower query counts.

PTR records

A TTL of 1800 to 3600 is recommended for pointer records since these record types may be changed somewhat frequently, depending on how they’re used. If you don’t plan to change them often, a higher TTL is recommended.