If so how do I do it?  I looked at the mod_perl docs and found:
Apache2::Response->set_keep_alive()

The example:
$ret = $r->set_keepalive();

That overrides the default KeepAlive setting for this particular request.

Doesn't really make sense to me.  I already have the following in my
code:

$r->no_cache(1);

The adds HTTP headers instructing the client (and any proxies) that they shouldn't cache the page.

There's no relation between those two - they're doing completely separate things.

All that KeepAlive does is allow a client to request multiple resources on the same connection. Instead of

connect
request resource
disconnect
connect
request resource
disconnect

the browser can do:

connect
request resource
request resource
disconnect


This generally works out bad for a mod_perl server, as you end up with a large number of apache processes, and therefore a large amount of server resources just sat around waiting to see if any further requests are going to come in on that connection.

For a basic apache install, that's mainly serving static content KeepAlive is an advantage as it reduces the amount of time spent opening and closing connections. Remember that in most situations you're going to serve a page, followed by some images and stylesheets.

So if you have a front-end/back-end setup the best config is:

KeepAlive Off

in the back-end mod_perl servers, and On in the front-end static/proxy servers.

Carl

Reply via email to