Sometimes, you may need to configure DNS records to connect a domain to a web hosting server. When setting up DNS records, you can specify the TTL value. Typically, you would leave the default value provided by your domain registrar or web hosting provider when adding DNS records.
A WordPress user raised a question about whether it's advisable to set a low TTL value when adding domain records, so let's briefly explore this topic.
Understanding Domain DNS Settings: TTL, Name Servers, A Records, and CNAME
TTL (Time To Live) is a crucial parameter in the Domain Name System (DNS) that indicates how long a DNS record remains valid within the network. TTL determines the duration for which a domain's IP address information is cached and retained.
Thus, in theory, some people might believe that setting a short TTL allows DNS changes to propagate more quickly, which could be beneficial.
Effects of Setting a Short TTL Value
Setting a short TTL value has several key effects:
- Fast Propagation of DNS Records
- DNS changes propagate more quickly and are reflected sooner.
- Clients can cache new record information more quickly.
- Advantages
- Setting a very short TTL can result in record changes being reflected almost in real-time.
- Allows for rapid updates to the latest information.
- Disadvantages
- Increases the number of queries to the DNS server.
- May lead to increased server load.
- Potential for increased network traffic.
- Practical Strategy
- Consider setting a low value (e.g. 300 seconds) before making changes,
- and then restore it to a higher TTL value post-change.
Therefore, while a short TTL value isn't automatically better, it's essential to adjust it thoughtfully according to the service's characteristics. As mentioned above, you might maintain a low TTL until the DNS records are fully propagated, then switch to a higher value afterward.
Understanding the Default TTL of 14400
Most domain registrars and web hosting companies I utilize set the default TTL value at 14400 when configuring a domain's DNS records. (This value can be adjusted during setup.)
For instance, if you’re using Chemicloud and change your domain's nameservers to the information provided by Chemicloud, you can add records such as A, CNAME, and TXT in the Zone Editor of cPanel. (Chemicloud, a cost-effective option with fast speeds, offers Seoul servers for enhanced speed in South Korea.)
Upon clicking the Add Record button, the TTL value will default to 14400.
A TTL of 14400 corresponds to seconds, equating to 4 hours. When the DNS record is set to a TTL value of 14400 seconds, it functions as follows:
- When the domain information changes,
- it can take up to 4 hours for all DNS servers and caches to reflect these changes.
Most domain registrars and web hosting services establish a default TTL of 14400 seconds (or 4 hours), which is a reliable setting considering that DNS changes are not frequent in typical website operations.
When changing a server's IP address, it usually takes 3 to 4 hours for the DNS record changes to propagate, which is based on the assumption of the TTL being set at 14400 seconds.
For stable service operations, values between 3600 seconds (1 hour) and 86400 seconds (24 hours) are typically recommended for TTL. However, during planned server migrations or significant updates, you might temporarily reduce the TTL to a shorter duration (e.g., 300 seconds or 5 minutes) for quicker updates.
I tend to stick with the default value. If I decide to shorten it, I would revert to a higher value (e.g., 14400) once I believe the DNS records have propagated sufficiently.
Differences Between Changing Name Servers and Setting A Records
Changing name servers and setting A records are two critical tasks in DNS management, but they serve distinct purposes and have specific impacts.
Changing name servers means updating the address of the servers responsible for a domain's DNS services. Some web hosts require this change when you want to connect your domain to their servers. You can modify your domain's name servers to the information provided by hosts such as Cafe24, FastComet, or Chemicloud. If you intend to manage DNS through Cloudflare, you would need to change the name servers to those specified by Cloudflare.
When you change the name servers, control over all DNS records for the domain is transferred to the new name servers. This means you can set A records, CNAMEs, and other DNS records at the designated name servers. Propagation of changes when updating name servers typically takes about 1 to 2 days.
In contrast, setting an A record involves linking a specific domain name (e.g., www.example.com) directly to the server's IP address hosting that website. The A record specifies exactly which server the domain connects to, and if the IP address of the website changes, the A record must be updated. A records can be configured where the name server is designated, allowing for quicker incorporation into the DNS system compared to altering the entire domain's name server settings.
Name server changes take about 1 to 2 days to fully propagate, while A record changes generally take around 3 to 4 hours.
A Records and CNAME
A records and CNAME records are types of DNS records used for resolving domain names. Each record type serves to map domain names to server IP addresses in different ways.
An A record (address record) maps a domain name directly to an IPv4 address. For instance, if the server connected to example.com has an IP address of 192.1.2.3, you can set this IP address in the A record for that domain. A records provide the most straightforward and direct way to link a domain name to a specific server location. They are particularly utilized for hosting web servers or other online services, enabling direct and fast responses during DNS lookups.
On the other hand, a CNAME record (canonical name record) maps one domain name to another domain name, with the actual IP address resolution being handled by the A record of the mapped domain. For example, when setting DNS records like the following (if connecting a domain to Cloudways, you might configure it similarly):
example.com -> 192.1.2.3 (A record)
www.example.com -> example.com (CNAME)
In this scenario, the CNAME record for www.example.com points to example.com, and the final IP address is derived from the A record specified for example.com. CNAME records are mainly used to manage subdomains or when multiple domains connect to the same IP address.
The primary difference between these two record types is that A records directly map to IP addresses, while CNAME records map through another domain name. A records provide faster responses compared to CNAME records, but CNAME records offer greater flexibility and convenience in management. It's essential to select the appropriate record type based on your specific use case.
For example, if you want to connect a personal domain to Tistory, a free blogging platform in South Korea, you can choose between setting an A record or a CNAME.
Setting an A record allows for speed benefits, yet requires modification if Tistory’s server IP address changes for proper access. Although a CNAME may be slightly slower, you wouldn't need to adjust it in case Tistory changes its server IP.