How to Reduce Time to First Byte (TTFB)?
For anyone, a fast website makes a noticeable difference. Even search engines appreciate faster websites compared to the slower ones. But when it comes to rankings, yes a fast website will help but not over the engaging contents.
In technical terms, Time to First Byte, in short TTFB is a measurement used as an indication of the responsiveness of the web servers and similar network resources.
TTFB is a duration from the user making an HTTP request to the first byte of a page being received by the user’s browser. Short time means a fast loading website while more time will result in multiplying slowing effects.
Look at the image, I have loaded my subscribe page while using the DevTools.
In the image, we can see the subscribe document started receiving its content in 47 ms, while most of the visible content (images, styles, scripts, etc.) loaded in 132 ms. Some deferred and non-visible resources loaded just after some milliseconds – 337 ms. This shows how fast is a website. Note that each and every millisecond matter here, because initial load time will decide how fast the rest of the content will load.
Can we reduce the TTFB time?
Yes, there are few ways we can make it super fast, but that will come with the cost of using some extra tech. But the best thing is a few of them can be achieved for free while some of them are affordable these days.
- Use the fastest domain name system service. Cloudflare is the fastest & free one.
- Switch to a faster host. Avoid shared and cheaper servers.
- Make use of fast and latest web server applications. PHP7 and Nginx.
- Make use of caching wherever needed. FastCGI is the most reliable one.
- Take advantage of CDN efficiently for global delivery.
1. Use the fastest domain name system service.
The domain name system resolver resolved the domain name and IP address. Every server has one or many IP address/es like 192.168.0.1 which is not fancy at all and only useful to machines. So we use the domain names which are easy to remember.
Many domain registrars offer a domain management dashboard. It helps to manage the domains to propagate, resolves, and handle all the modifications in the records. But they could be slow and frequent changes will take you to a long route because they are slow and not utilizing modern routing techniques.
There are many Free and Paid DNS services like Amazon Route 53, GoDaddy Premium DNS, Google Cloud DNS, and Cloudflare.
We suggest Cloudflare DNS over any slow one because it is free and the fastest one. Look at the world wide availability of their presence, they are almost everywhere.
To use Cloudflare DNS services all you need to do is, point the name servers to Cloudflare and add all the DNS entries and DO NOT ENABLE the cloud icon. Allow the changes to propagate. Once everything is running on Cloudflare DNS you will see a slight improvement in DNS.
According to DNSPerf, these are the list of all well known DNS service.
2. Switch to a faster host.
You may never know but your web hosting server may slow your website down to a larger extent. If you are using a shared hosting service then chances are high.
Usually, a shared server suffers from a high waiting time because of other busy peers and the use of heavy software like cPanel and WHM to control the shared users. Also shared servers are using outdated hardware and software packages due to compatibility issues so you won’t be able to take advantage of newer launch.
PHP7 was launched on 15th December 2015, which was known for its tremendous improvements in performance and stability, but it took over 3 years for the hosting companies to adopt it. Similarly, the apache web server is still the first choice for shared and managed servers which are known for the OHKAY performance in the industry. Nginx and OpenLiteSpeed are the newer and fastest ones.
Hardware-wise, the use of SSD, NVMe drives to enhance the system responsiveness which is not available in cheaper shared web hosting servers. If you are planning to host a blog, eCommerce, forum, and website then use SSD based hosting servers.
3. Make use of fast and latest web server.
Once you decide to buy a web hosting server, make sure you use it with all the latest apps. You can take advantage of the Nginx server with FastCGI cache to eliminate any concurrent load on the server. Nginx can handle static content very well.
Similarly, you can make use of the latest PHP 7.4 version.
PHP 7 came with many noticeable improvements and now it has been upgraded to 7.4 which took everything to the fastest performance we can achieve in the same hardware resources. Look at the image to understand the difference.
But before you install the latest PHP version make sure your site is fully compatible with it. WordPress in its official documentation said that they are supporting the latest version of PHP and in the coming days they will drop the support for older versions. So just make sure the theme and plugins are upgraded recently.
4. Make use of caching wherever needed.
WordPress is a dynamic CMS we all know that, if you are using it as a blog or website then caching will eliminate the need of generating the same page again and again. Cached contents can be served faster because it is already available to download.
Available caching options with WordPress:
- FastCGI Cache, a server-level cache (Nginx) [Recommended]
- WP Super Cache, easiest one (WP Plugin) [Recommended]
- W3 Total Cache, not recommended to smaller sites (WP Plugin)
- Cloudflare, only for 100% static websites (Full Page Proxy Cache)
From the above options, you can use anyone based on your setup. If you are using Nginx better use FastCGI cache which will eliminate the need for a cache plugin. Since it is a server-side cache it is the fastest and more efficient one. You can server the cache directly from the server memory, which means the network will be the limit.
If you want plugin based caching option then use WP Super Cache or W3 Total Cache.
Cloudflare can be used as page caching using full page cache, but only recommended when a website is purely static and the content will hardly change over time.
The limitation is you need to manually purge the cache from Cloudflare if you made any minor changes in WordPress. Note that Cloudflare’s full page cache won’t work well with blogs and forums, it is only useful when you have a static website.
Let’s say you made a website with WordPress and nothing is going to change, use full page cache offered by Cloudflare. It will be the fastest setup anyone can achieve.
5. Take advantage of CDN for global delivery.
Now we come to a different case where we want to serve the website to the world.
Here we can use CDN (Content Delivery Network) to deliver the static contents very quickly by delivering the static resources to the user from his nearest available PoP (Point of Presence) CDN servers.
It is a really challenging job to sustain TTFB for web pages, but we can improve the loading speed of static resources by hosting them close to users. This is where CDN comes in. A CDN service can have as many as PoP (Point of Presence) possible. But more presence means addition in the monthly fees. So choose wisely.
I recommend starting with BunnyCDN (referral link), as they have good availability in the world by placing their network presence in the most strategic places while maintaining the lowest cost which makes it an affordable to use CDN service.
This is all, as of now we have the above technology to improve our website’s TTFB. In the coming days, we will see HTTP/3 and QUIC which is about making a certificate secured connection (HTTPS connection) faster.
Please raise a comment if you are confused, have any query, or feedback for us.