When users visit your website, you want them to receive the most up-to-date information.
However, you also need your site to load quickly. Otherwise, you risk a bounce, where the user gives up and leaves your site quickly.
Fortunately, you can find a balance by adjusting your website’s Time to Live (TTL). You can use it to improve your site’s loading time and keep the information current.
In this guide, we’ll look at what TTL is and how it works. We’ll also examine what it’s used for and how you can choose the right TTL value for your site.
Let’s get started!
What Is TTL?
TTL — which, as we’ve mentioned, stands for “Time to Live” — is a setting that determines how long your data (in packet form) is valid and available from within a network before the router clears it.
We can also refer to this time as “hops,” which is the number of times it bounces between different routers.
Once the TTL expires, the router will need to retrieve the information again, along with its updates.
TTL is also used by Content Delivery Networks (CDNs) to cache your data. CDNs are server networks worldwide that host static files, so visitors to your site will receive the closest information to them.
This determines how long the CDN will hold onto your data before it retrieves updated information.
We’ll take a more in-depth look at exactly how this functions later in the article. For now, let’s examine what TTL is in the context of Domain Name System (DNS) servers, pings, and Internet Protocol (IP) headers. TTL functions differently for each of these applications, so it’s important to understand the distinctions.
What Is TTL in DNS?
DNS servers act as a bridge between web servers and domain names. When you type in a domain name like “Kinsta.com”, servers cannot interpret this information. They read data in numbers known as IP addresses.
So DNS facilitates the conversion between domain names and IP addresses, and enables users to access websites.
To understand the relationship between DNS servers and TTL, we first need to look at the cache. In this context, the cache is a storage for the conversion of your website’s domain name into its IP address.
Every time a user wants to access your website, this conversion needs to happen. If the conversion is stored in the cache, the connection can happen more quickly because there is a DNS record. In fact, the server can pull up the record almost instantaneously.
In this context, TTL determines how long a DNS server will hold onto this DNS record before it requests the information again. It’s one factor that controls DNS propagation, which determines how long a DNS takes to update.
What Is TTL in a Ping?
Ping is a measurement of your connection’s reaction time. For example, it measures how long a request that you send out takes to return. This ping measurement is one of the ways that you can measure network latency, which is a general term for your connection’s responsiveness and delay.
When you run a ping test, the report may contain the TTL. This TTL value can give you more information about how long your connection takes to complete.
During this test, the ping records the results from four separate packets of data. It displays the amount of time taken and the TTL, which shows how many “hops” these packets of data took.
However, this report does not show you the TTL set by the other website’s server. Therefore, you would need to know that value to calculate the true TTL.
What Are TTL Values?
When you set TTL values for your website, you choose a value in seconds. For example, a TTL value of 600 is the equivalent of 600 seconds or ten minutes.
The minimum available TTL is usually 30, equivalent to 30 seconds. You could theoretically set a TTL as low as one second. However, most sites use a default TTL of 3600 (one hour). The maximum TTL that you can apply is 86,400 (24 hours).
Technically, you can set any TTL value between the minimum and maximum parameters. Later in this article, we’ll discuss how you can choose the best time to live value for your site.
What IPv6 Field Is Similar to the TTL Field in IPv4 Packets?
IPv6 and IPv4 are different kinds of IPs. They both route packets of data through a series of rules (or protocols). These IPs contain information that enables data to arrive at its intended destination.
IP headers contain the information at the beginning of a packet of data. For example, they have information about the IP addresses from the source and the destination, among other details.
IPv4 is the original IP, and it has been available since 1984. It has a 32-bit address that is made up of numbers and periods. IPv6 is a newer IP, and it uses a 128-bit address format that has letters and numbers.
When you use an IPv4 header, it uses the TTL field, but IPv6 does not. With an IPv6 header, it has a field called Hop Limit that acts similarly to TTL. Here you can see a comparison of the two IP headers.
The Hop Limit determines how many “hops” a data packet will move before the router discards it.
How Does TTL Work?
Now, let’s take a more in-depth look at how TTL actually works. We already know that its value determines how much time (or how many hops) a data packet will exist for before a router rejects it. However, the way that this functions is a little more complex than you might imagine.
When you assign a TTL to your packet data, it carries this number as a numerical value in seconds. Every time the packet reaches a router, the router takes away one number from the TTL value and passes it along to the next step in the chain.
If the data packet is passed along too many times, its numerical value will reach zero. If this happens, it will fail to make the whole connection, and the router will discard it.
You will then receive an Internet Control Message Protocol (ICMP), which is a type of error message. For example, if your data has a TTL of 300, it can only pass through different routers a maximum of 300 times.
What Is TTL Used For?
We’ve seen so far that there are various applications for TTL. If you have a website, your main concern is probably how quickly your site loads. If your content is too slow to load, you could lose visitors and potential customers. Additionally, slow loading sites are detrimental to Search Engine Optimization (SEO).
Therefore, let’s analyze TTL in the context of caching. Your website comprises a series of pages, code, images, and other content that can take a long time to load. If all of this content has to reload with every user, it can significantly slow down your site’s speed.
You can use a longer TTL to make your cached site exist for longer before it updates. Consequently, your site will load much faster, and it will put less pressure on the server.
However, short TTLs can also be beneficial in some contexts. For example, websites that update constantly can benefit from a shorter TTL. A site like Xe uses real-time currency conversions, and so a long TTL could make its data redundant.
Additionally, short TTLs can protect your site against Distributed-Denial-of-Service (DDoS) attacks. These attacks happen when an entity overwhelms your website with thousands of requests from different locations in a short period. A short TTL can help protect your site because the frequent DNS updates are available to the blocking controls.
You may also want to change your DNS TTL before planned edits to your site, such as if you are adding a new website or updating the IP address for a server. The old information will be cached for the period of the TTL, so you may need to reduce it according to your timeline.
How Should You Choose a TTL?
Deciding on a suitable TTL for your needs can be challenging. Fortunately, there are some general guidelines that you can follow to see what fits your site best.
We recommend a TTL of 1-24 hours for most sites. Remember that TTL values are measured in seconds, so this is the equivalent of 3,600 to 86,400 seconds.
This TTL value can reduce loading time, which improves the user experience for your visitors and can decrease your bounce rate. The longer the better is a general rule, but remember to schedule any website maintenance accordingly.
If you own a registry website, you may want to choose a TTL of around one hour (3,600 seconds). These sites are high-level domains that may end in “.org” or “.com”. For example, Verisign is a registry website:
We advise changing your TTL to around 300 seconds (five minutes) before any operational changes to your site, especially if they’ll impact the DNS. Otherwise, the updates may not come into effect in a timely manner.
We also recommend a TTL of 300 seconds for sites that are vulnerable to DDoS attacks. If you have fierce competition in your field, a competitor’s website may try to put you out of action with one of these attacks. Additionally, controversial or whistleblowing websites are also potential targets for DDoS.
Finally, we recommend a short TTL of 300 seconds for DNS-based load balancing. This is when multiple servers are sharing traffic by providing various IP addresses for server requests. By doing so, the system reduces strain on a single server.
How Can You Change Your TTL?
Hopefully, by now you will have a good idea of what TTL value you want for your site. Now we can see how to change this value on a Kinsta site.
You can change the TTL of your DNS records quite easily with Kinsta. This customizable setting is available with the Kinsta DNS menu in your Kinsta dashboard’s sidebar.
Navigate to Kinsta DNS and add your domain. Click on the chosen domain to add and view DNS records. From there, you can click on Add a DNS record > TTL.
From the drop-down menu, you can choose a TTL from one hour to four weeks. One hour is the default. We don’t recommend going beyond 24 hours unless your DNS has very infrequent changes and updates.
There are many other DNS records that you can change here, so we recommend checking out our guide to adding DNS records to Kinsta DNS. If you don’t use Kinsta for your hosting, you may need to check directly with your hosting provider to find out how to adjust TTL values.
TTL is an essential setting that enables you to control how long a server stores your site’s information. You can make your TTL longer or shorter to decrease your page load time, keep data up-to-date, and avoid DDoS attacks.
You can set your TTL as low as 30 seconds or as high as 24 hours. However, for most general sites, a TTL between 1 and 24 hours provides an excellent balance. By choosing this value, you can keep your site loading quickly and still showing current data.
If you want to decrease your site’s loading time, you’ll love using Kinsta application hosting, database hosting, and managed WordPress hosting. All of Kinsta’s hosting plans include speed-optimized architecture to get your site loading in no time!