Reusing a Connection Between HTTP Exchanges
Several HTTP exchanges can share an underlying connection when protocol, peer, and implementation rules permit it.
- Source
- Anbloq
- Language
- English
- Created
- Updated
- Chapters
- 4
- Reading time
- 1 min
In this article4 chapters
Trace a batch of reads
A client retrieving three small documents may avoid establishing a new connection for each one. The messages still have distinct request and response semantics. See the request structure.
Check which work is being timed
A first request can include establishment and negotiation, while a later one reuses that work. Measure both when appropriate and record the conditions. Elapsed request time describes what the caller observes.[1]
Compare a sequence with and without repeated setup
A client makes two requests to the same origin over a compatible persistent connection. The second can avoid some connection setup because it uses the existing transport. HTTP versions differ in how several exchanges can share a connection and overlap. See request and reply timing.
Case A: connect → first request → second request on same connection
Case B: connect for each request
Track setup, response and possible idle closure separately
Handle connection closure according to the request's semantics
A server or intermediary can close an idle connection. A new request may need another connection, and repeating an in-flight request can have application implications. Verify reuse and safe failure behavior with the supported client.