Keep-Alive

Keep-Alive is an HTTP header that allows a web server to use a single connection for multiple requests from a web browser. Servers running HTTP/1 often have keep-alive turned on to improve website performance. The keep-alive header is not used in HTTP/2 since it is the default behavior of the HTTP/2 protocol.

When Keep-Alive is enabled on a web server, it creates persistent connections between the server and clients (website visitors). The TCP connection stays open until it is closed or times out. Since each TCP connection must complete a handshake process, multiple connections increase the page load time. Keep-Alive provides a way for browsers to download all webpage assets, such as images and CSS files, over a single connection.

The disadvantage of Keep-Alive is that it requires more system resources from the web server. If websites on a server receive a lot of traffic, it may have several — possibly several thousand — persistent connections open at once. Eventually, the server may not be able to handle new connections and become unresponsive. Apache provides the following directives to prevent servers from reaching maximum capacity:

  1. KeepAliveTimeout - the maximum time a persistent connection can stay open while waiting for new requests
  2. MaxKeepAliveRequests - the maximum number of requests allowed within a single connection, before it needs to be reset

To enable keep-alive on an Apache server, add the following code to a server-wide include file or the .HTACCESS file of a specific website:

<IfModule mod_headers.c>
    Header set Connection keep-alive
</IfModule>
Updated May 27, 2021 by Per C.

quizTest Your Knowledge

Which of the following is an example of a MIME type?

A
text/html
0%
B
.TXT
0%
C
TextEdit
0%
D
https://
0%
Correct! Incorrect!     View the MIME Type definition.
More Quizzes →

The Tech Terms Computer Dictionary

The definition of Keep-Alive on this page is an original definition written by the TechTerms.com team. If you would like to reference this page or cite this definition, please use the green citation links above.

The goal of TechTerms.com is to explain computer terminology in a way that is easy to understand. We strive for simplicity and accuracy with every definition we publish. If you have feedback about this definition or would like to suggest a new technical term, please contact us.

Sign up for the free TechTerms Newsletter

How often would you like to receive an email?

You can unsubscribe or change your frequency setting at any time using the links available in each email.

Questions? Please contact us.