TTL

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.

TTL (Time To Live) is a setting in DNS records that specifies the duration in seconds for which a record is considered valid and can be stored in a resolver's cache. It dictates the interval between requests to the authoritative DNS server for updated information about a domain's IP address or other attributes.

How it works

When a DNS resolver receives a query, it checks its local cache. If the requested record is present and its TTL has not expired, the resolver provides the cached data. Once the TTL reaches zero, the record is discarded, and the next query triggers a recursive lookup to fetch fresh data from the authoritative source.

  • Short TTL (e.g., 60 seconds): Ideal for critical updates, failover scenarios, or during server migrations to ensure rapid propagation of changes.
  • Long TTL (e.g., 86400 seconds): Reduces DNS traffic and improves resolution speed for end-users, as the data remains in the cache for 24 hours.

A common practice for production environments is setting a TTL of 3600 seconds (1 hour). For example, if you plan to change an A record, you should lower the TTL to 300 seconds a day in advance to ensure that the transition happens quickly across the global DNS infrastructure.