9

Is it possible to disable Keep-Alive on a directory basis?

For example, I have an API that runs on something like domain.com/api/

It'd be nice if KeepAlive was not used on any requests in the /api/ directory.


Update/Solution:

SetEnvIf Request_URI /api/ nokeepalive

Source: http://httpd.apache.org/docs/2.2/env.html

NNN
  • 404
  • 5
  • 8

3 Answers3

7

This seems to be a recent feature of Apache HTTPD, but it works.

To disable (turn off) Keep-Alive for a specific directory, use:

SetEnvIf Request_URI /myDir/ nokeepalive

Add this to your httpd.conf or .htaccess file!

Source: Environment Variables in Apache - Special Purpose Environment Variables - nokeepalive.

acdcjunior
  • 132,397
  • 37
  • 331
  • 304
1

There are 2 ways I found: 1. As described by acdcjunior you can do it with SetEnvIf inside your Virtual host or main configuration SetEnvIf Request_URI /myDir/ nokeepalive 2. You can just set the Connection header to close Header set Connection "close"

I prefer the second option due to the fact that this will allow the entire configuration to be under the

0

No! the context for the keep-alive directive is: server config, virtual host

Itamar Lavender
  • 959
  • 7
  • 20