The TTL (Time To Live) value of your website is greatly important to how people experience your site. It can ensure that people are always seeing the newest/most relevant version of your website. But how does it do that? What is the ideal Time To Live for your website? ⏰
In this post, we’ll look at what TTL means, and how it impacts your site. Along the way, we’ll show you how it connects with the Domain Name System (DNS) and also how to check the TTL of your site.
📚 Table of contents:
- Explaining the Domain Name System
- Defining Time To Live
- Why you should keep tabs on TTL
- How to choose a Time To Live value
- How to check Time To Live for Windows, macOS, and Linux
Explaining the Domain Name System (DNS)
The DNS essentially helps your computer find websites by looking up its names too. When you type a website address (like domainwheel.com) into your browser, your computer has to find that website. It’s like knowing someone’s name but not their phone number or address.
As such, the DNS stores the domain names and associated IP addresses for every website on the internet.
When you want to browse to domainwheel.com, your computer requests the server’s IP address from the DNS. From there, the computer can then use the IP address to connect to the website’s server, just like you’d use a phone number to call someone.
The beauty of DNS is that it’s much easier for us to remember a domain name over a bunch of numbers. However, the relationship between a domain name and an IP address can change, which means you may otherwise “call the wrong number”. This is where we use the Time To Live value.
Defining Time To Live (TTL)
When you visit a website or use an app, your computer stores information from that site using caching and cookies to help speed up access next time. However, in the same way food can go bad after a while, internet information can become outdated too.
Time To Live is a “best before” label for information on the internet. Just like food products have an expiration date that tells you when food goes bad, TTL tells a server how long it can trust certain information.
How TTL works with the DNS to resolve a domain
To mitigate outdated information, the TTL value provides a time limit for how long your computer should hold onto a piece of information before it checks on its validity.
For example, if a website’s IP address changes, the old address your computer has might not work anymore. However, your computer will go back to the source once the TTL expires to ask if the information is still accurate or if there’s a new version.
TTL ultimately helps keep the internet running smoothly by encouraging computers to regularly verify and update the information it uses. This ensures your computer won’t keep requesting an IP address every time you visit the same website, and also helps to retain processing resources.
DNS Propagation and how this links with TTL
Of course, there isn’t only one server in the world. As such, whenever you make a change to the DNS records of a domain (like switching to a new web server), every DNS server on the internet has to know.
DNS propagation is the entire process for spreading these updated DNS records across the global network of servers. However, it often takes some time for every DNS server receive this new information.
This is, in part, due to the TTL value. A DNS server will wait until the TTL expires before it updates its DNS records. For example, take a TTL of four hours – the minimum for a site hosted with a company like Bluehost.
Even if you make changes now, DNS servers will still use the old records for up to four hours before it considers the new changes. The TTL essentially sets the pace for DNS servers to adapt to the new information.
Over time, all of the DNS servers synchronize and the new records fully propagate. This prevents a sudden and chaotic switch, and ensures a smooth transition for everyone involved.
Why you should keep tabs on TTL (and use cases)
Keeping track of your Time To Live values is essential if you want to maintain reliability and efficiency for your site’s experience.
👉 At a basic level, adjusting to a short TTL value will speed up propagation. As such, the end user will see the updated content sooner. This is perfect for tasks such as site migrations. However, there are deeper reasons why you should optimize your TTL:
- If you ever need to make a sudden change to your website’s configuration, a low TTL can help you implement those changes quickly and effectively. This is particularly important for business critical or time-sensitive updates.
- If you use load balancing to help distribute traffic among multiple servers, a low TTL can ensure that traffic redirects to healthy servers promptly. This maintains the availability and performance of your site.
- A Content Delivery Network (CDN) often needs a suitable TTL for its DNS records. This lets you control how often the CDN retrieves fresh content from your origin server. It also ensures your users can see your latest content without delays caused by old, cached data.
- Adjusting your TTL values before you change email providers, domain registrars, and other services can make a transition smoother. Again, this lets you reduce potential disruption time.
Reading all of this, it’s tempting to use the lowest TTL possible as standard at all times. However, a super-low TTL can increase the load on DNS servers due to more frequent queries for updates. Finding the right balance for your TTL values is crucial to prevent overwhelming DNS servers.
How to choose a Time To Live value
In reality, lots of site owners won’t worry about TTL. This is because many hosts will offer a default TTL value, or provide a pre-set selection of values. These Time To Live values are usually adequate for most websites.
👉 However, there are times when you may not want to opt for the default:
- If you need to make changes such as switching servers or updating IP addresses, a temporarily low TTL can propagate those changes quicker. Once the propagation completes, you can set a longer TTL time again.
- Websites that rely on real-time data or have constant updates – currency conversion platforms or social media sites, for example – will use a low TTL such as 30–900 seconds. Some web hosts don’t allow for Time To Live values this low, so if you want to use a TTL this low, you’ll want to look up the minimum TTL for the web host you’re considering.
- Low TTLs can also protect against Distributed Denial of Service (DDoS) attacks. In a nutshell, this is because of the constant DNS refreshes that take place.
- Higher TTL values can reduce loading times, which will benefit your visitors and site analytics.
In instances when you need lower TTL times, 300 seconds (five minutes) is usually suitable. If your content is rarely updated, you might want to go as long as a day (86,400 seconds) or even a week (604,800 seconds) to improve site loading times.
How to check Time To Live for Windows, macOS, and Linux
There are two ways to check TTL depending on your operating system (OS). We’ll cover both of them below.
Note that while you’ll need to use the command line to do this, you don’t need advanced technical knowledge. Finding access to the command line is beyond the scope of this article, but each OS has its own default app – the Command Prompt for Windows and Terminal for macOS and Linux.
1. Use nslookup with Windows
With the Command Prompt open, enter the following command and run it. Remember to replace the placeholder domain with the site you’d like to check:
nslookup -debug www.domainwheel.com
You’ll see a set of results. Somewhere within the results will be a section that shows the TTL value in seconds.
You’re able to repeat this as many times as you like, although you can simply close the Command Prompt once you finish.
2. Use dig with macOS and Linux
On macOS and Linux, you use the
dig command rather than
nslookup. the straightforward approach is to run
dig domainwheel.com (and replace the domain with your site). This will return a batch of information.
If you scroll to the ANSWER SECTION:, you’ll see your DNS ‘A’ records complete with the current TTL value:
However, you can return just the TTL information if you use a longer command:
dig +nocmd +noall +answer +ttlid a domainwheel.com
This strips away all of the other data and simplifies the output.
It may not seem that way, but optimizing your TTL values can bring a lot of good to your site. For instance, you can ensure visitors see updates quicker than usual.
This will be important for fast-paced sites such as social media. In some situations, you’ll even be able to help protect it against against DDoS attacks. ⚔️
The starting point is to check your site’s TTL times using the command prompt. From there, you can begin to optimize your site further!
👉 Searching for the TTL of your competitors can give you an insight into their level of success. Our article on how to check website traffic for any site will help you understand their visitor levels too!