Time to Live (TTL)
What is TTL?
In networking, time to live (TTL) determines how long to cache either a query or content. The TTL meaning differs based on the kind of TTL being described.
As you figure out what TTL means, you have to 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 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.
At that point, 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 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 figure out 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 error messages 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.