What is TTL?

Author: Published

In brief: TTL (Time To Live) is a parameter that determines how long data can remain valid or how long a packet can travel through a network. In domain settings, TTL primarily means how long a DNS response is cached, usually expressed in seconds. A lower value helps changes become visible sooner, but does not guarantee that all users will see them at the same time.

What does TTL mean in DNS?

DNS is a system that allows services associated with a domain name to be located, such as the IP address of a website’s server. This information is stored in records: an A record specifies an IPv4 address, while an MX record specifies the servers that handle email. TTL accompanies this data and indicates how long a cached response can be used without retrieving it from the source again.

User queries are often handled by a DNS resolver, a server that looks up answers and caches them. This means it does not have to query the authoritative server—the server publishing the domain’s actual records—every time someone visits the website.

If a record has a TTL of 3600, its response can normally be cached for one hour from the time it is retrieved. A value of 300 means five minutes, and 86400 means one day. TTL does not indicate how long a domain registration is valid or when an HTTPS certificate expires.

How does TTL affect a change to a website’s address?

Suppose a domain’s A record points to the old hosting server and has a TTL of 3600 seconds. A resolver retrieves it at 12:00, and at 12:10 you change the IP address to the new one. That resolver may continue returning the old address until around 13:00, because the earlier response remains valid in its cache.

Another resolver, which first queries the record at 12:15, may already receive the new address. This is why, after a DNS change, some people reach the new server while others still reach the old one. This does not necessarily indicate a configuration error.

Changing TTL does not retroactively shorten the lifetime of responses already stored in other caches. If you change the IP address and lower the TTL from one day to five minutes at the same time, earlier copies may remain valid according to the old value.

The term “DNS propagation” is sometimes used as shorthand for this process. However, it is not a single global mechanism that distributes the change at a fixed time. Independent caches, updates to the DNS provider’s servers, and sometimes the behaviour of the operating system or application all play a part. TTL is therefore an important timing guideline, not a promise of the exact moment when all users will switch over.

What TTL value should you choose?

The choice depends on how often you change the record and how important it is for responses to be refreshed quickly. The values below are examples of possible uses, not mandatory settings.

SituationExample TTLReason
Planned website migration300 secondsShortens the period during which the old response is used, if you lower the TTL in advance
Normal website operation3600 secondsA compromise between refreshing responses and using the cache
A record that rarely changes86400 secondsAllows cached data to be used for longer

A low TTL means more frequent queries to authoritative servers. A high TTL reduces the number of these queries, but makes it harder to roll back an unsuccessful change quickly. Lowering TTL alone does not speed up image downloads or the execution of website code.

Not every provider allows you to enter any value you like. The control panel may enforce a minimum, offer an “automatic” option, or manage TTL itself for services that act as intermediaries for traffic. Check your DNS operator’s current documentation for the meaning of these settings and the available range.

How should you prepare TTL before a hosting migration?

The most important step is to lower TTL sufficiently early, before changing the destination server. For a record whose current TTL is one day, plan to lower the value at least one day before switching over, counting from when the change is published on the authoritative servers.

  1. Check the current records and their TTL values. Identify which addresses you are changing; the website may use both an A record and an AAAA record specifying an IPv6 address.
  2. Lower the TTL of those records, for example to 300 seconds, if the provider allows it. Wait for the previous TTL period to elapse.
  3. Prepare the new hosting. Check that the website, HTTPS certificate and database connection work before changing DNS.
  4. Change the records and monitor both servers. Do not shut down the old hosting immediately. For an online shop or forms, also ensure data consistency during the transition.
  5. Once operation has stabilised, restore the normal TTL, if the short interval is no longer needed.

This procedure applies to changes to service records. Changing a domain’s nameservers also involves delegation, which specifies which servers are responsible for its DNS. Lowering the A record’s TTL alone does not control that entire switchover.

What does TTL mean outside DNS?

In IPv4 packets, TTL limits the number of hops through routers. Although the name refers to time, in practice each router forwarding the packet decreases this value by one; once it is exhausted, the packet is discarded. This protects the network against packets circulating endlessly in a loop. The equivalent in IPv6 is the Hop Limit field.

TTL also appears in application caches, where it defines how long a stored result remains valid, such as a response retrieved from an API. Always check the context: TTL displayed alongside a domain record refers to DNS, while TTL in the output of the ping command refers to a network packet.

If you are preparing to change hosting, start by checking the current TTL—it will help you determine how far in advance to begin preparations.

Read also

Learn how PHP-FPM handles PHP requests, how it differs from a web server, and how to tune processes for traffic and hosting resources.
Learn how BIND, open-source DNS server software, handles domains, how its two roles differ and when running it yourself makes sense.
Learn what Poland’s REGON register and identification number mean, how they differ from NIP and KRS, and how to check a business’s details.