Reputation: 414
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
Upvotes: 9
Views: 4474
Reputation: 43
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
Upvotes: 1
Reputation: 135792
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.
Upvotes: 7
Reputation: 1028
No! the context for the keep-alive directive is: server config, virtual host
Upvotes: 0