How can I enable keep-alive?

John Doe picture John Doe · Nov 22, 2011 · Viewed 42.5k times · Source

I ran a Google Page Speed and it says I scored 57/100 because I need to "Enable Keep-Alive" and "Enable Compression". I did some Google searches but I can't find anything. I even contacted my domain provider and asked them to turn it on, but they said it was already on.

Long story short:

1.) What is Keep-Alive?

2.) How do I enable it?

Answer

Tamik Soziev picture Tamik Soziev · Jul 11, 2012

Configure Apache KeepAlive settings

Open up apache’s configuration file and look for the following settings. On Centos this file is called httpd.conf and is located in /etc/httpd/conf. The following settings are noteworthy:

  • KeepAlive: Switches KeepAlive on or off. Put in “KeepAlive on” to turn it on and “KeepAlive off” to turn it off.

  • MaxKeepAliveRequests: The maximum number of requests a single persistent connection will service. A number between 50 and 75 would be plenty.

  • KeepAliveTimeout: How long should the server wait for new requests from connected clients. The default is 15 seconds which is way too high. Set it to between 1 and 5 seconds to avoid having processes wasting RAM while waiting for requests.

Read more about benefits of keep alive connection here: http://abdussamad.com/archives/169-Apache-optimization:-KeepAlive-On-or-Off.html