Published on 2022-02-25
TTL stands for Time to Live. For your DNS records, this means the amount of time that a record is kept in cache. If the TTL is longer, the resolver will hold the information in cache for longer. If you chose a TTL 0f 1800 seconds, your server will store the information for 30 minutes. If a user uses the same resolver, there will be no query on the server while the TTL is still active.
TTL is important because it impacts the query volume your service will have. Too short a TTL could increase query volume and lead to longer change propagation for users.
Keeping TTL as short as possible is useful when managing traffic so that users requesting the name get the most recent information. TTLs of less than 30 seconds are not generally useful as the servers will not modify times below that threshold.
For records that rarely change, keeping those between an hour and one day is the common practice. If necessary, when these records change, TTL can be shortened to allow the change to be propagated.
Start of Authority (SOA) TTLs are at the top of the DNS zone. They override TTL settings below and should not be modified except under rare circumstances.
SOA TTL—how often the SOA record is refreshed.
Refresh TTL—how often the secondary DNS refreshes the primary server.
Retry TTL—how often the secondary server will retry to refresh the primary zone file if the initial refresh fails.
Expiry TTL—if refresh and retry keep failing, this TTL will dictate how long the primary server will retain authority. After this duration, it will be deemed unreachable.
NX TTL—if the request returns a non-existent query, this is called an NXDOMAIN. The NX TTL is the amount of time that the recursor alots before returning the NXDOMAIN response.