SOLVED Keep Alive is enabled, but it's not working

PumpinIron

Member
Mar 8, 2013
22
0
1
cPanel Access Level
Root Administrator
According to my WHM Apache configuration, keep alive is enabled.

However, according to this check tool, it's not:
giftofspeed.com/check-keep-alive/index.php

Also, testing my site on GTMetrix shows it isn't enabled either:
gtmetrix.com

I've rebooted the server, reconfigured Apache, etc., but it's still telling me it's not enabled, even though it shows it is via WHM.

Any thoughts on what this is? HostGator refuses to help even though I'm paying them for a "managed" dedicated server.
 

NOC_Serverpoint

Well-Known Member
Jul 3, 2016
103
7
18
cPanel Access Level
Website Owner
Hi,

After logging into WHM, find the section called “Service Configuration” and choose “Apache Configuration” from the list below. This will present you with a number of configuration sections. The one we are interested in is called “Global Configuration".

This will bring us to a screen with a lot of options that control various aspects of Apache. Scroll down until you .

find the WHM “Keep-Alive” parameter:

Even though the default is “On”, you may find it turned off occasionally.

Also, under this “Keep-Alive Timeout” needs to be set.
This controls the number of seconds a server must wait before automatically closing a connection. A higher value means that a browser has more time to request stuff over the same connection, but consequently it means that a greater strain is being placed on the server as it locks up resources.

The default value of five seconds may need to be tweaked depending on the power of your server as, the traffic it gets, as well as the kind of webpages you have. After saving your changes, the WHM GUI will present you with a list of saved settings where you can confirm that your changes have taken effect.

After saving changes, you need to restart Apache.

Thanks
 

rpvw

Well-Known Member
Jul 18, 2013
1,100
479
113
UK
cPanel Access Level
Root Administrator
I am not sure the site you are using is reading the server response headers correctly.

I tried it on a number of my sites and they all failed - BUT the response headers all said something like
snip.....
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Vary: Accept-Encoding,User-Agent
Content-Encoding: gzip
Content-Length: 8515
Keep-Alive: timeout=5, max=93
Connection: Keep-Alive
Content-Type: text/html; charset=utf-8

200 OK
Perhaps you should try another tool like WebPagetest - Website Performance and Optimization Test
 

PumpinIron

Member
Mar 8, 2013
22
0
1
cPanel Access Level
Root Administrator
I am not sure the site you are using is reading the server response headers correctly.

I tried it on a number of my sites and they all failed - BUT the response headers all said something like Perhaps you should try another tool like WebPagetest - Website Performance and Optimization Test
Well, that page says Keep Alive is enabled, but gives me a B score, and then says this:

Screen Shot 2016-12-06 at 9.15.05 AM.png

I'm so lost... Some of these sites are telling me Keep-Alive is enabled (even though they say it failed), while others are just telling me flat out that it isn't enabled.

Another one is http://gtmetrix.com, which tells me Keep-Alive is enabled, but that it doesn't work on any of my URLs.
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,880
2,270
463
Hello,

Feel free to open a support ticket using the link in my signature so we can take a closer look. You can post the ticket number here and we will update this thread with the outcome.

Thank you.
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,880
2,270
463
Hello,

To update, the issue was addressed by removing the following entry from /usr/local/apache/conf/includes/pre_virtualhost_global.conf:

KeepAlive Off

Note that a KeepAlive session is only initiated if the client requests a KeepAlive session. The following entries must be added to the .htaccess file to enable this setting by default:

Code:
<ifModule mod_headers.c>
Header set Connection keep-alive
</ifModule>
Thank you.