Do HTTP/1.1 persistent connections timeout

http

It is my understanding that HTTP/1.1 persistent connections stay open until the client closes them (via a close request header).

If this header is not present, does the host close this connection after a set period of time (timeout) if no further requests from that specific client are made?

Best Answer

Yes they timeout after a pre-specified keep-alive timeout. (5 seconds by default on Apache: http://httpd.apache.org/docs/2.4/mod/core.html#keepalivetimeout).

Without this servers would be vulnerable to keeping connections alive forever (wasting resources) for those that don't close the connection nicely or can't (e.g. A mobile that drops off the network suddenly).

Tuning your keep alive timeout can give performance gains to clients (as they don't need to initiate a full reconnection) but at cost of memory in the server to manage that connection.