TTFB (Time to First Byte) is the time between the user and the server when the user visits the website for the very first time. It has three things included, namely DNS lookup, SSL Handshaking and Server Processing Time.
In Shared Hosting environment, SSL Handshaking and Server Processing have taken from the WebHost, and you only have to think about how you will optimise the TTFB of your website via DNS.
How DNS Works
DNS is like the number plate of your house. When you visit a website, the address you entered converted to one or more Internet addresses by DNS Resolver. So, your computer gets the IP address and visit specific Internet Address to retrieve the information.
How to check DNS Resolver works
In Linux or Macs, you open the terminal and type dig example.com, and you will get the following response. If you have trouble, try this, dig @126.96.36.199 example.com.
; <<>> DiG 9.10.6 <<>> example.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 30708
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0
;; QUESTION SECTION:
;example.com. IN A
;; ANSWER SECTION:
example.com. 82024 IN A 188.8.131.52
;; Query time: 100 msec
;; SERVER: 192.168.1.1#53(192.168.1.1)
;; WHEN: Fri Oct 30 02:06:11 +0630 2020
;; MSG SIZE rcvd: 45
How fast is your DNS responses?
The DNS resolution should be in 100 ms. If your DNS resolution is over 200 ms, you should check with your hosting provider.
Tune your DNS?
You can tune your DNS in a set of ways.
- DNS Hosting
- CNAME loop
On your side, DNS Hosting is one of the popular ways if your hosting provider is slow in resolving your domain names. The DNS solving methods is solely rely on your domain provider, but you cannot say if your domain name is with limited functionality.
The Second way is CNAME loop. If your website has records of multiple CNAMEs, you should shrink down to specific ones or change them with A Records.
The third one is caching. Your DNS can stay as cache in specific servers. This method is on the client-side, and you have less control, but if your clients have a lot of caching routers and devices, you are lucky enough to serve your client faster internet.