Well, most of the time, Keep-Alive gets automatically enabled on the web servers. But in some cases, you’ve to do that manually. In order to activate the keep alive, you have to add the following code to the HTTP header in your server.
You can also do that by using .htaccess in WordPress or by editing the configuration file of your Apache/ NGINX servers.
In fact, there are several other ways to enable Keep-Alive in WordPress. Wanna learn how to do that? Come with us, and let’s provide you with some best practices to Enable Keep-Alive in WordPress. But first of all, let’s see what actually Keep-Alive Is? And how it works?
What is Keep-Alive?
Keep-Alive is a method for enabling a TCP link to access several server-to-web files instead of generating new links on each specific request. Keep-Alive is also called a persistent HTTP connection.
As your visitor’s browser just needs to open one persistent HTTP connection instead of multiple connections, the browsing speed will increase significantly.
Okay, now let’s see how it actually works!!
How Does Keep-Alive Work?
Probably, you’re familiar with the connection and the coordination process between the browser and the server. Okay, let’s make this more clear for you.
A connection between the server and browser is established when you visit a website. At the same time, the browser asks the server to access a particular file, and the server allows it to the browser.
Thus, your browser will start downloading the file. This cycle repeats for the second file, and the process goes on.
Suppose that your web server needs ten files to display a particular webpage. In this case, the browsers have to build ten different links for each download and ask OK to view each file one by one.
But when you’ve enabled Keep-Alive, the browser can accomplish this entire task with a single connection. The browsers will be able to use this connection and access all the files with a single OK from the server. As the number of requests reduces, the server load gets decreases too. Consequently, the page loading speed of your site will improve considerably.
How to Enable Keep-Alive in WordPress
Your page-loading speed bears the utmost importance for several factors, either you’re an owner of a blog or a website. With the simple techniques of enabling Keep-Alive in WordPress, you can boost your webpage and its loading speed.
But before using any methods, it’s recommended to check your webpage if Keep-Alive is already enabled or not. It’s because many renowned Hosting Companies provide Keep-Alive by default.
Whatever, if the Keep-Alive isn’t enabled, then add this following code .htaccess file.
Header set Connection keep-alive
Find out the last line of your .htaccess file and add this code in it. It’ll enable Keep-Alive by adding the Keep-Alive HTTP headers.
In some cases, the .htaccess didn’t is unlocated because it wasn’t created automatically with the installation of WordPress. Then you’ve to create one by yourself.
Enabling Keep-Alive in Apache
Apache servers are usually enabled with Keep-Alive. But if it isn’t for yours, find the Apache HTTP server configuration file.
You can get them from here- /etc/httpd/conf/httpd.conf
Once you’ve found the file write the code below
# Set it On to enable Keep-Alive, Off to disable Keep-Alive KeepAlive On # Set maximum requests per connection, set 0 for unlimited request, 100 request per connection is ideal MaxKeepAliveRequests 100 # Set per connection timeout for next request KeepAliveTimeout 15
Enabling Keep-Alive in NGINX
NGINX servers also come with Keep-Alive enabled by default. But if it’s not, check for the same files by locating ‘keepalive_disable’ in NGINX core module (ngx_http_core_module).
So, do your website is Keep-Alive enabled or not. If you aren’t sure, make sure to check it. However, if it’s not, then follow the above methods to enable Keep-Alive and make your webpages faster than ever. Hope the above guide will be useful for you.