====== DNS TTL (Time To Live) ====== **TTL (Time To Live)** is a value associated with every DNS record that specifies how long a recursive DNS resolver may cache the record before querying the authoritative DNS server again. TTL is measured in **seconds**. ----- ===== Why Does TTL Exist? ===== Without caching, every DNS query would require contacting the authoritative DNS server. Caching reduces: * DNS lookup time * Internet traffic * Load on authoritative DNS servers TTL tells recursive resolvers how long they may use a cached answer. ----- ===== Example ===== Suppose the following record exists: example.com. 3600 IN A 93.184.216.34 Here: * Domain: `example.com` * Record Type: `A` * IP Address: `93.184.216.34` * TTL: `3600 seconds` A recursive resolver may cache this record for **one hour**. ----- ===== How TTL Works ===== The first user requests: example.com The resolver: * Queries the authoritative DNS server. * Receives the answer. * Stores it in its cache. * Starts the TTL countdown. Subsequent users receive the cached answer until the TTL expires. User │ ▼ Recursive Resolver │ (Cache) TTL = 3600 s When the TTL reaches zero, the resolver performs a new lookup. ----- ===== Typical TTL Values ===== ^ TTL ^ Meaning ^ Typical Usage ^ | 60 | 1 minute | Testing or frequently changing records | | 300 | 5 minutes | Dynamic services | | 900 | 15 minutes | Moderate changes | | 3600 | 1 hour | Common default | | 86400 | 24 hours | Stable records | ----- ===== TTL and DNS Propagation ===== TTL directly affects **DNS propagation**. Suppose: Old Record: 93.184.216.34 TTL: 3600 If you change the IP address immediately after a resolver caches the old record, that resolver may continue serving the old address for up to: 3600 seconds even though the authoritative server already contains the new record. ----- ===== Lowering TTL Before DNS Changes ===== When planning a DNS migration: - Lower the TTL several hours (or one day) before the change. - Wait until the old TTL has expired. - Change the DNS record. - Increase the TTL again after propagation is complete. Example: Day 1 TTL = 86400 ↓ Lower TTL to 300 ↓ Wait 24 hours ↓ Change IP Address ↓ Most users update within 5 minutes ----- ===== Does TTL Guarantee Propagation Time? ===== No. TTL specifies the **maximum recommended cache lifetime**. Some resolvers: * Respect TTL exactly. * Cache records for shorter periods. * In rare cases, cache records longer than the published TTL due to implementation or policy. Therefore propagation time is usually close to—but not always exactly equal to—the TTL. ----- ===== Common Misconceptions ===== * **TTL delays updates on the authoritative server.** * False. Changes appear immediately on the authoritative server. * **TTL tells clients how long to connect to an IP address.** * False. TTL only controls DNS caching. * **Lower TTL always improves performance.** * False. Lower TTL increases DNS traffic and load on authoritative servers. ----- ===== Best Practices ===== * Use a long TTL (1–24 hours) for stable records. * Lower the TTL before planned DNS migrations. * Avoid unnecessarily short TTL values for production systems. ----- ===== Checking TTL ===== DNS lookup tools display the remaining TTL returned by the queried DNS server. Example: example.com A Record: 93.184.216.34 TTL: 287 A remaining TTL of 287 seconds means the resolver will likely continue serving the cached record for another 287 seconds before querying the authoritative server again. ----- ===== TTL and Telenegar DNS Check ===== Telenegar DNS Check displays the TTL returned by each DNS server. Comparing TTL values from multiple resolvers can help identify: * Cached responses * DNS propagation status * Resolver refresh timing ----- ===== Related Topics ===== * [[networking:dns:dns|DNS Explained]] * [[networking:dns:dns-propagation|DNS Propagation]] * [[networking:dns:recursive-authoritative|Recursive vs Authoritative DNS]] * [[tools:dnscheck|DNS Check]] ----- {{tag>dns ttl cache propagation resolver authoritative}}