Enable Keep-Alive

Updated on Mar 13, 2019

Method Type: Server
(this means that this method is handled by the Server side configuration)

Status: Enabled by default on all FastComet Hosting Servers.

Introduction:

The Transmission Control Protocol (TCP) is a core protocol for major internet applications like the World Wide Web, email, file transfer and remote administrator. The Hypertext Transfer Protocol (HTTP) is an application protocol and the foundation of data communication for the World Wide Web.

How Keep-Alive works:

When a TCP connection is opened on it will be sent only one HTTP request /response pair. Keep-Alive is build with the idea of sending multiple HTTP requests/responses via one TCP connection thus significantly reducing the time needed for the web browser to load files from the web server.

Keep-Alive is utilized to the fullest when dealing with static content like images as it allows the requestor to get all of the images from the page using one TCP connection instead of opening new ones for each image. On plain text pages Keep-Alive will not bring a significant improvement because there is little amount of content to be requested, for example an HTML page with a text body will not require more than one TCP connection even if Keep-Alive is disabled. However on media content reach pages it will provide significant improvement in page loading speed.

Keep-alive provides the following Advantages:

  • Reducing latency in subsequent requests.
  • Faster data retrieval as the TCP connection stays open after the first request has been handled.
  • Minimising the chance of queueing delay, packet loss or blocking new connections due to a network congestion.
  • Errors being reported without the need of closing the TCP connection.
  • No need for additional handshakes after the first request has been handled.

If you want to enable Keep-Alive on your own server you can do so via the .htaccess file if the mod headers are supported by your hosting provider.

Then you will need to add this line to your .htaccess file:

<IfModule mod_headers.c>

Header set Connection keep-alive

</IfModule>

This way you will add keep alive headers to your requests which will force the Keep-Alive method on your connection.

Another way to enable Keep-Alive is by using the Apache config file. You can access it via SSH by navigating to:

/usr/local/apache/conf/httpd.conf

From there you can add the following lines to enable Keep-Alive:

<ifModule mod_headers.c> Header set Connection keep-alive </ifModule>

You can also enable this Method by using the cPanel in VHM. You need to access the Apache Configuration section which is located in the Service Configuration menu. Then you will need to click on the Global Configuration option for Apache.

Accessing the Apache Configuration Menu

You will now see a lot of configuration options for Apache including the Keep-Alive option which you can turn on.

Enabling the Keep-Alive option in the Global Configuration for Apache

Hit the Save button at the bottom of the page to apply the change.

On this page...

    Optimized SSD Web Hosting

    • Free Domain Transfer
    • Google PageSpeed Enabled
    • 24/7 Technical Support
    • Fast SSD Storage
    • Hack-free Protection
    • Free Cloudflare CDN
    • Immediate Activation
    View More