How to use keep-alive connections to improve performance

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?

Related Articles

'403 Forbidden' error message

Problem You get a "403 Forbidden" error notice when you try to access your site with a web...

How to disable entity tags (ETags)

This article will show you how to stop your website from sending entity tags (ETags) in HTTP...

How to install Apache Tomcat

Apache Tomcat is a well-known and dependable open-source Java web server. Tomcat is a Java HTTP...

How to troubleshoot CGI scripts

If your CGI (Common Gateway Interface) script isn't working, try the following troubleshooting...

How to use Server-Side Includes (SSI)

This tutorial will show you how to set up and use Apache Server-Side Includes (SSI) on your...