Skip to content Skip to navigation Skip to footer

What is TTL? Meaning in DNS and CDN

Time to live (TTL) is the length of time or “hops” that a packet may move through a network before being discarded by a router, or how long content or a query is retained in DNS and CDN caching.

As you learn what TTL means, you must differentiate between Domain Name System (DNS) TTL and content delivery network (CDN) TTL. DNS TTL instructs the DNS resolver as to the amount of time it needs to cache a query before it requests a new one. This information is stored within the recursive or local resolver’s cache that handles the TTL until it has to collect new details.

CDN TTL is different in that it refers to the caching of content. This involves keeping a copy of the resources on a website on CDN proxies to make the page load faster and to reduce the amount of bandwidth consumed.

DNS TTL is expressed in terms of time because it determines the amount of time before the resolver gathers the details of a website. For example, if the DNS TTL of Fortinet.com were set to 900 seconds (15 minutes), the resolver would gather details about Fortinet.com once every 15 minutes. During that 15-minute period, every user that went to Fortinet.com would see the exact same thing. If 2,000 users went to Fortinet.com between 12:00 p.m. and 12:15 p.m., they would all see the same text, images, links, etc. 

However, even if an update was performed on the website at 12:10 p.m., it would not take effect until the DNS TTL went back to gather more details for the site at 12:15 p.m. Therefore, a user who went to Fortinet.com at 12:16 p.m. would see the updated content, but a user who visited at 12:14 p.m. would see whatever was there between 12:00 p.m. and 12:15 p.m.

How Does TTL Work?

TTL's basic function revolves around managing information packets in relation to DNS requests. When one of these packets is created and transmitted through the internet, there is a chance that it will pass, continuously, from router to router forever. To prevent this from happening, each packet has a specific TTL or hop limit. It is also possible to examine the TTL log of a data packet to obtain information on how it has moved through the internet over the course of its travels.

Within each packet, there is a specified place where the TTL value is stored. This is a numerical value, and it indicates how much longer the packet should move around the internet. When a router receives a data packet, it takes away one unit from the TTL count before sending it on to the next destination within the network. This continues to happen until the TTL count within the packet drops all the way down to zero. 

Once expired, the router gets rid of the data packet and transmits an Internet Control Message Protocol (ICMP) message to the host where the packet originated from. ICMP is a protocol that allows devices to communicate with each other and convey errors regarding the flow of data packets.

To illustrate how TTL works, it helps to see how it is used by tracerouting, particularly with Internet Protocol version 6 (IPv6). IPv6 refers to an IP address that is a 128-bit alphanumeric string used to identify an endpoint. With IPv6, TTL refers to the hop limit or the number of stops a data packet is allowed to hop to before it causes an error to be sent back via ICMP.

This allows TTL to be used to gather information on how a data packet moves through the internet. With Transmission Control Protocol/Internet Protocol (TCP/IP), data packets typically do not travel in a straight line as they go from their source to their destination. They bounce from one node to another, eventually reaching the designated endpoint. 

Tracerouting is used to check figure how long it takes for a data packet to go from one place to another as it makes its trip through the internet. During the execution of a traceroute command, there is a stream of packets that gets sent along a path. Each packet has a TTL value that is one more than the one before it. This means it can go one step farther without sending an error using ICMP. The feedback sent through ICMP are used to determine the amount of time it took for each data packet to hop to each spot along the network as it traveled towards its destination.

How does TTL Work?

What is DNS TTL Used For?

DNS TTLs are particularly useful for websites that constantly and frequently change their web content. With a lower TTL, a website can receive the most recent updates more often. For example, if a fictional company named ABC Widgets had a website called GetWidgets.com, and it had a TTL value of 3,600 seconds (one hour), it would receive updates once every hour. However, if GetWidgets.com performed frequent updates, it could adjust the TTL value to make it update more frequently.

TTL management can be particularly helpful when optimizing the user experience for your customers. In the GetWidgets.com example, the company may need to add products on a continuous basis, particularly as they ramp up for a busy selling season. 

For instance, their staff may be uploading product descriptions, images, and videos for new widgets all day, every day. If their TTL were to remain at 3,600 seconds, online shoppers would have to wait an hour to see the latest products available. However, if they reduced their TTL time, website customers would be updated more frequently, giving them a more accurate view of the available widgets.

On the other hand, if each product page had to undergo a careful review process before being approved for the website, ABC Widgets may want to adjust the TTL to allow for the time it takes to complete each review.

DNS TTL is also useful because it provides the user a cached version of the website. If an organization’s website has a lot of content and takes a long time to load, the caching process can make it easier for users to access the content because it is stored in the cache. This enables large sites to still be readily accessible by a larger number of users.

Because DNS TTL manages the caching of a website, an organization can also use it to optimize the user’s experience according to the limitations of the servers they use. Caching eases the burden on your central server by storing a version of the website in a layer that is easily accessible by the end-user. 

If your company’s server is stretched to the max, you could increase the DNS TTL to make it send a new version of the site less frequently. This way, the server only has to undergo the strenuous work of pushing out an updated version of the entire site every so often. The DNS TTL, in this case, would be allowing the server time to “rest” before reaching to get a fresh copy of the website.

Conversely, if your organization’s website has an interactive application programming interface (API) that is central to the customer experience, you may want to adjust your TTL to enhance the site’s performance from the user’s perspective. In some cases, a lower TTL value could yield better results because the user gets an updated version of the site more frequently. 

For example, if you were using the Yahoo Finance API, you may want users to see the most updated financial information on companies mentioned on your site. With a lower DNS TTL setting, the user would have access to more recent company data.

Learn more about DNS Firewall.

How Fortinet Can Help

One of the primary advantages of properly managing your TTL is maintaining smooth, efficient uptime for your website. Often, because a business’s operation hinges on the performance of its online assets, optimizing TTL and the performance of online applications is of paramount importance. The Fortinet FortiGSLB Cloud ensures maximum uptime, regardless of the situation.

This Global Server Load Balance (GSLB) Cloud is a powerful business continuity tool because it keeps an application online and ready in the event of unexpected spikes in usage or even if the network goes down.

Also, with GSLB, you can set up redundant resources in strategically selected locations around the world. This enables you to accommodate instantaneous failover, all managed with an integrated API, ensuring your customers always have access to the applications most important to your business.