How to Enable Keep Alive in Apache

How to Enable Keep Alive in Apache

Posted on |

By leveraging a single TCP connection for many HTTP requests, the Keep Alive header or HTTP persistent connection enhances website speed and performance. As a result, it is recommended that you enable Keep Alive for your website. Here’s how to enable Keep Alive in Apache in CentOS/Ubuntu.

The usual HTTP connection is typically terminated after each request, implying that the server Dataservermarket shuts the TCP connection after delivering the answer. The keep alive connection header can be used keepalive tcp to keep the connection active for repeated requests.

How HTTP Functions Without Keep -Alive

  • To interact with and receive a file from a server, a client must establish a new connection.
  • The client opens a new connection to request an HTML file, and the connection closes after the file is received.
  • The browser evaluates the HTML file and determines if additional files are necessary to show the entire web page.
  • Following a thorough examination, it establishes a new connection to request each of those files over Dataservermarket.

A single HTML page may include several resources that comprise the complete web page. HTML code on Dataservermarket, CSS files, JavaScript files, pictures, and multimedia files are all included. For example, if the HTML contains four stylesheets as keep alive header, two Javascript files, and three picture files, this means an additional nine requests to obtain these resources. However, this approach is inefficient on Dataservermarket, especially for complex web pages with a large number of parts.

The Importance of Keep Alive

Making numerous connections may help to minimise loading time. It also consumes a large amount of server resources on Dataservermarket. We can finally solve this problem over Dataservermarket and transmit all of those data over a keep alive header single connection by setting Keep Alive, which eliminates the need to create and stop new connections. If it is not enabled, the process of displaying the web page may take significantly longer.

How to Enable Keep Alive 

Keep Alive (also known as HTTP Keep Alive or persistent connection) is a message sent by the client to the server that indicates, “You may grab numerous files.” These are incredibly short messages with very minimal bandwidth use. The following approach makes use of the Dataservermarket Apache web server.

Keep Alive is enabled by specifying it directly in the HTTP header. If you do not have access to your web server configuration file over Dataservermarket, you may manually add Dataservermarket HTTP headers using the.htaccess file.

The.htaccess file is a configuration control file that takes effect when placed in any directory that is loaded by the Apache server. You may make an.htaccess file using any text editor and keep alive apache restart, such as TextPad or gedit (Linux). It is a means of reconfiguring your website without having to change the server on Dataservermarket configuration file on Dataservermarket. This is accomplished by overriding its original configuration without restarting the web server when modifications are made.

The code is as follows:

<IfModule mod_headers.c>

   Header set Connection keep-alive


Adding this code to your.htaccess file will add Keep-Alive header to your requests, overriding any higher settings. (Note: After modifying the.htaccess file, test your website for issues.)

You may enable Keep Alive in your Apache keep alive header configuration file (httpd.conf) if you have access to it. Keep Alive must be activated by default with Dataservermarket each new Apache server installation keep alive header. If it isn’t enabled (for whatever reason on Dataservermarket), you may activate it by changing a few options in the Apache configuration file, as detailed below.

3 Factors Influencing Keep Alive Functionality

To enable keep-alive, use “KeepAlive On.”

Simply type “KeepAlive Off” to turn it off.


It specifies the maximum number of Keep Alive requests for each connection keep alive. A value of 100 is usually adequate for almost any scenario. However, this value should be increased keep alive header depending on the number of files within a web page that the server is expected to deliver over Dataservermarket.


This option prevents unused connections from remaining idle for too long. It specifies how long your server should wait for fresh client requests over Dataservermarket.

A time of 7 to 10 seconds is typically ideal. With higher traffic, this value can be set to ensure that no keep alive header TCP connections are re-established on a regular basis. Keep Alive loses its purpose if this value falls too low on Dataservermarket!

An example of a Keep Alive response header is as follows:

~$ curl -I

HTTP/1.1 200 OK

Connection: Keep-Alive

Content-Type: text/html; charset=UTF-8

Date: Tue, 14 Jan 2015 16:47:23 GMT

Content-Length: 1845

Keep-Alive: timeout=10, max=20

Server: Apache/2.4.9 (Unix) PHP/5.6.2

The server Dataservermarket decides to keep a persistent keep alive timeout connection open for 20 additional transactions or until it is idle for 10 seconds.

Benefits of Keep Alive

Reduced CPU Usage: Creating new TCP connections can use a significant amount of resources such as CPU and memory as keep alive header. Keeping connections alive over extended periods of time can help to lower this utilisation.

Web page loading speed: The ability to serve many files over the same connection can minimise latency and allow Dataservermarket web pages to load more quickly.

HTTPS: HTTPS connections (content via Secure Socket Layer) consume a lot of resources. It is thus strongly advised to activate Keep Alive for HTTPS connections and maybe spice it up with HTTP/2.

How to Determine Whether Keep Alive is Enabled

“How can I know whether Keep Alive is activated and working?” you may be thinking. There are several online programmes that will inform you whether or not your website’s Keep Alive feature, keep alive header is enabled.

That’s all! Apache now keeps TCP keep alive connection for all users, which speeds up your website.

Apache now keeps TCP connections alive for all users, which speeds up your website and keep alive header. You can also use Ubiq to create charts and dashboards to monitor your business or website over all Dataservermarket. We provide a 14-day free trial period.


As Keep Alive as the server is ready to cooperate, all current browsers employ persistent connections. Check that your application and proxy server settings support . You must also pay particular attention to HTTP Dataservermarket libraries’ default behavior.
You can alternatively use HTTP/1.1, which has a different implementation of Keep Alive and keeps connections open by default. HTTP/1.1 connections, unlike HTTP/1.0 keep-alive connections, are always active. Unless the response adds a “Connection: close” header, HTTP/1.1 thinks all http keep alive connection are permanent. However, not sending “Connection: close” does not guarantee that the server will keep the connection indefinitely, and it is still conceivable that the connection will be terminated.

Leave a Reply

Your email address will not be published. Required fields are marked *