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

How to enable keep-alive connections

Keep-alive connections handle many HTTP requests and responses over a single TCP connection. Keep-alive connections allow clients and servers to interact more efficiently and use less resources by not starting a new TCP connection every time a browser sends a request.

Many performance testing sites, such as GTMetrix, check to see if a site's keep-alive connections are enabled. If they are disabled, your site performance score suffers.

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
    </IfModule>
    
  3. Save your changes to the .htaccess file. Keep-alive connections are now enabled.

Was this answer helpful? 0 Users Found This Useful (0 Votes) apache web server