Forum Moderators: phranque

Message Too Old, No Replies

Connection: close

apache KeepAlive directive not working

         

jamie

12:00 pm on Mar 25, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



hi,

i have

KeepAlive On

in my httpd.conf

but everytime i check headers of my pages, it says

Connection: close.

If i manually send headers

header("Connection: keep-alive");  
header("keep-alive: timeout=15, max=100");

then checking headers gives the following:

Connection: keep-alive, close 
keep-alive: timeout=15, max=100

there must be some reason why apache is sending connection: close headers? the funny thing is, on my dev server, which has identical config in every way - the correct keep-alive headers are being sent?

can anyone help?

dmorison

1:04 pm on Mar 25, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Could you be looking at headers inserted by a proxy server between you and your live box?

jamie

2:51 pm on Mar 25, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



that sounds plausible, but i don't think that is the case.

i just ssh'd to the live server and did telnet localhost 80 then GET /index.html HTTP/1.0 - and still received a Connection: close header. (surely this would bypass any proxies?)

is there another way to test this?

many thanks

p.s. as a matter of interest the only website i have found which specifies the "Connection: keep-alive" is google.com. all other sites, including WW, show Connection: close headers

Lord Majestic

3:08 pm on Mar 25, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



GET /index.html HTTP/1.0

I think its default behavior to all HTTP/1.0 requests, try specifying HTTP/1.1 in your request and its a good idea to let server know that you support persistent connections by specifying header:

Connection: Keep-Alive

jamie

5:53 pm on Mar 25, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



hi lord majestic, thanks.

when i send the

Connection: keep-alive
header separately in my script, the results are as above:

Connection: keep-alive, close 
keep-alive: timeout=15, max=100

so the close is still being sent.

what i still don't understand is why the apache

KeepAlive On
directive doesn't appear to be working?

p.s. the HTTP/1.1 returned a

HTTP/1.1 400 Bad Request
header

Lord Majestic

6:03 pm on Mar 25, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Do you talk to server via proxy or directly?

Also can you post FULL headers that you get from server. Also note that keep-alive won't be enforced is Content-Length is not known -- this should cover your PHP script.

You are likely to be getting BadRequest result for HTTP/1.1 because you MUST specify Host header.

jamie

6:19 pm on Mar 25, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



hi lord majestic,

>> Do you talk to server via proxy or directly?
as far as i know, directly, but i don't know a way to test that?

The full headers from a webpage using a server header checker:

HTTP/1.1 200 OK  
Date: Fri, 25 Mar 2005 18:17:39 GMT
Server: Apache/1.3.26 (Unix) Debian GNU/Linux mod_gzip/1.3.26.1a mod_ssl/2.8.9 OpenSSL/0.9.6c
Last-Modified: Fri, 25 Mar 2005 17:49:00 GMT
ETag: "526112431a2591c9965a410c8b28ab26"
Connection: close
Content-Type: text/html; charset=iso-8859-1
Content-Encoding: gzip
Content-Length: 4553

(i specifically send content length header in the php scripts).

here are the full headers from telnet localhost 80

GET / HTTP/1.1 
Host:www.mysite.com

HTTP/1.1 200 OK 
Date: Fri, 25 Mar 2005 18:12:55 GMT
Server: Apache/1.3.26 (Unix) Debian GNU/Linux mod_gzip/1.3.26.1a mod_ssl/2.8.9 OpenSSL/0.9.6c
Last-Modified: Fri, 12 Nov 2004 10:25:53 GMT
ETag: "5c8019-1f3-41948fb1"
Accept-Ranges: bytes
Content-Length: 499
Content-Type: text/html; charset=iso-8859-1

does this shed any light on the matter?

many thanks

EDIT: Lord majestic, panic over. i can now see the keep alive headers

Status: HTTP/1.1 200 OK
Date: Fri, 25 Mar 2005 18:21:33 GMT
Server: Apache/1.3.26 (Unix) Debian GNU/Linux mod_gzip/1.3.26.1a mod_ssl/2.8.9 OpenSSL/0.9.6c
Last-Modified: Fri, 25 Mar 2005 18:19:28 GMT
ETag: "83651502de4d7d357dc0bd9ae2be2a51"
Content-length: 14145
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
Content-Type: text/html; charset=iso-8859-1

i used brett's server headers checker instead of the firefox view response headers, and as you can see above, the keep alives are working fine.

apologies for the confusion!