Whenever the browser requests a file from the server, interaction takes place between the server and browser it creates a communication pattern that is keep-alive.
Benefits of using Keep-Alive
- Minimizes latency and an overall increase in loading speed and performance.
- Better site performance will be an advantage in terms of SEO and ranking.
- Minimizes the usage of CPU and memory due to a lesser number of the generated HTTP requests. This is an advantage to all hosting plan users (free hosting, shared hosting, and VPS).
- It provides HTTP pipelining which means same TCP connection is used to deliver requests
- All modern browsers support Keep-Alive
- Additional benefits will be added to you if your website uses HTTPS and SSL certificates.
You may also like to read:- How to Fix Serve Resources from a Consistent URL?
How to enable Keep Alive?
Firstly, you need to determine whether Keep Alive is enabled or disabled on your server. Analyze your website using a tool such as GTmetrix.
In case of Apache
You can choose one of the following ways:
- Open Apache configuration file on server and add.
Your server needs to be restarted after adding this.
2. .htaccess file, add the below code
Header set Connection keep-alive
In case of NGINX
If Keep Alive is disabled in your config file, you will find the following in the file.
You can use below code to make changes in the settings:
To sum up, improved site speed and performance will eventually keep your visitors happy.