Sign up ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I have only acces to the php.ini file and my good old .htaccess file.

Where do I enable the Keep Alive setting?

( Im on a plesk 8.2 )

share|improve this question

2 Answers 2

up vote 2 down vote accepted

Which KeepAlive setting? If you are meaning whether the server supports persistent HTTP connections and how long the relevant timeouts are, then this is not something you can control from .htaccess or php.ini - it is something that can only be configured in the core Apache configuration files.

share|improve this answer
I see.. Bummer! But, is it likely virtual / shared hosters will enable it from a customers request? ( i have put on my naive trousers on for now ) – Sam Dec 16 '10 at 11:06
Most hosts will use the default, which is to have it enabled with a timeout of 15s. They may reduce that timeout to reduce server load (as more persistent connections hanging around for longer means needing more Apache workers to serve them), but I wouldn't have thought they'd turn it off as it can significantly reduce the load imposed by a client loading, for example, a HTML page that references many small graphics so is a benefit in a busy shared environment. – David Spillett Dec 16 '10 at 19:59

Of course You can!

Place .htaccess file with this content

(upload it using FTP or edit it using a SSH terminal)

<ifModule mod_env.c>
  SetEnv KeepAlive On
  SetEnv KeepAliveTimeout 100
  SetEnv MaxKeepAliveRequests 500

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

  Header unset Keep-Alive
  Header set Keep-Alive timeout=100,max=500

An even more dynamic than a htaccess folder-based configuration - is a PHP file based-one (and the headers too...) just add it to your PHP file. (Before you've started to output any content to the page)

  /* setting Apache */
  apache_setenv("KeepAlive", "On");
  apache_setenv("KeepAliveTimeout", "100");
  apache_setenv("MaxKeepAliveRequests", "500");

  /* setting headers */
  header("Connection: keep-alive");
  header("Keep-Alive: timeout=100, max=500");


From: iCompile - Keep-Alive - Apache And Headers By .htaccess And PHP

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.