Enabling keep alive allows the visitor’s browser to download the content files including images, javascript files, css files etc through a persistent TCP connection. This means it will not make different requests for each file and thus reduces the request amount and speed up a web page.
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.
KeepAlive On
Your server needs to be restarted after adding this.
2. .htaccess file, add the below code
<ifModule mod_headers.c>
Header set Connection keep-alive
</ifModule>
In case of NGINX
If Keep Alive is disabled in your config file, you will find the following in the file.
Keepalive_disable
You can use below code to make changes in the settings:
keepalive_requests
Keepalive_timeout
To sum up, improved site speed and performance will eventually keep your visitors happy.