How to use keep-alive connections to improve performance

This article describes how to use keep-alive connections in Apache to help improve performance.

How to enable keep-alive connections

Keep-alive connections use a single TCP connection to handle multiple HTTP requests and responses. Instead of opening a new TCP connection every time a brower sends a request, keep-alive connections enable clients and servers to communicate more efficiently and use fewer resources.

Many performance testing sites, such as GTMetrix, check if keep-alive connections are enabled for a site. If they are disabled, you receive a lower site performance score.

If keep-alive conections are disabled for your site, you can easily enable them. To do this, follow these steps:

  1. Edit or create an .htaccess file in your site's document root directory.
  2. Copy the following lines and paste them into the .htaccess file:
    <IfModule mod_headers.c>
        Header set Connection keep-alive
  3. Save your changes to the .htaccess file. Keep-alive connections are now enabled.

    To verify that keep-alive connections are enabled, you can examine the raw HTTP headers sent between the browser and web server. To do this, use a browser plugin that displays the raw headers such as Live HTTP headers for Mozilla Firefox, or the Developer Tools feature in Google Chrome. When keep-alive connections are enabled, Apache adds the following line to the HTTP response header:

    Connection: Keep-Alive


More Information

For more information about keep-alive connections, please visit

Did you find this article helpful? Then you'll love our support. Experience the A2 Hosting difference today and get a pre-secured, pre-optimized website. Check out our web hosting plans today.

Usamos cookies con el fin de personalizar para usted nuestro sitio Web y analizar el uso de éste. Usted acepta esto haciendo clic en “Acepto” o al continuar usando el sitio Web. Hay más información sobre cookies en nuestra política de privacidad.