How to reduce initial server response time?
Once you benchmark your website on tools, you might have encountered a red signal to reduce initial server response time. What is that?
In this article, we’ll learn about simple ways to reduce initial server response time.
What is the initial server response time?
It is the time it takes for the browser to receive the first byte in response to the browser request.
When a user tries to load a website. This initial connection consists of many transits which are linked to the first response like:
- Blocking time,
- DNS lookup time,
- Connecting time,
- SSL/TLS establishing time,
- Sending time,
- Waiting time,
- Receiving time.
If you are loading resources from multiple domains, or from CDN link then those steps are followed again in sequential order as requested by the browser.
1. Blocking time.
Blocking time is nothing but time taken by your computer to initiate the request. It is like a queue of a very small time to line your request.
Usually, blocking time is no more than 1 to 5 milliseconds.
2. DNS lookup time.
DNS (Domain Name System) is a hierarchical and decentralized naming system for computers connected to the internet.
DNS is like a map that knows what IP (Internet Protocol) address belongs to what domain and it resolves that using DNS resolution. The time taken to complete this resolution is known as DNS lookup time.
We all use the DNS service offered by the domain registrar or our hosting company. I’m not saying they all are bad, but not all of them are fast. Here I’ll recommend testing your own domain’s DNS lookup time worldwide using DNSPerf.
If you see that some regions are taking more than 100 milliseconds then use some alternate DNS service because this will be the first thing that will slow things down.
You can free DNS services like Cloudflare, or Premium ones like Amazon Route 53, GoDaddy Premium DNS, and Google Cloud DNS.
How to use Cloudflare as a DNS service: Just modify the domain’s name server to Cloudflare and add all DNS entries on Cloudflare’s dashboard, and set all the cloud icons to OFF, this way your domain will be managed by Cloudflare.
Just by switching to a fast DNS service, you can speed by 50-100 ms.
3. Connecting time.
Once DNS lookup is completed, the search of your server will start, and once found it will try to establish a connection. Usually, this process is fast but make sure you can maintain the same speed when users are increasing.
4. SSL/TLS establishing time.
This section will be followed if you have installed an SSL certificate on your website. If you are not using an SSL certificate you can ignore this point.
Establishing of SSL connection itself is hefty on server resources, but that can be resolved pretty easily by applying correct configurations.
I’ll suggest skipping all the outdated SSL Protocols (like TLS 1.0, 1.1) and use the latest ones only (like TLS 1.2 and 1.3). You can even cache SSL sessions to make things faster for new connections. Mozilla SSL Configuration Generator is one of tried and tested tools to generate all those optimized configurations.
You can save here significant processing time wasted due to misconfigurations.
5. Sending time.
Once the above communication completes, the browser sends a request to send the web page as the browser has established a secure connection to communicate.
6. Waiting time.
Once the server receives the request of the browser to send a web page, the server will create the web page and sends it to the browser. Here the performance of the webserver and overall codes will take time. Make sure you use the fast server and well-coded website theme and plugins so things get ready fast.
I’ve seen one issue with many clients that they install many plugins and disable most of them when they are not using them. This all leads to an increase in waiting time. Make the backend as much as lightweight you can, install and keep only important stuff and remove everything else which is of no use.
7. Receiving time.
Bonus. Use a CDN.
Content Delivery Network (CDN) comes in the scenario when you are dealing with a global level of traffic. You can not host your main website worldwide but you can serve all the static contents of your website using a CDN service.
If you have a fully static website, you can serve that whole site using CDN.
Note that, a dynamic website will not work correctly with CDN if you enable full page cache on the CDN end. So just cache contents only, not the dynamic pages.