NOTE

2.5 HTTP KeepAlive

Historical notes on HTTP KeepAlive, TCP connection reuse, and the difference from TCP keepalive.

Computer NetworksCreated Updated 1 min readhistorical

This is a historical learning note and may contain outdated or incomplete understanding.

1. What Is HTTP KeepAlive?

An HTTP persistent connection is a mechanism for reusing a TCP connection. In HTTP/1.0, each TCP connection could be used for only one HTTP transaction (request + response). HTTP/1.1 introduced HTTP Keep-Alive, which reuses one TCP connection for multiple HTTP transactions.

2. How HTTP KeepAlive Works

  • The client request header contains: Connection: KeepAlive

  • The server response header contains: Connection: KeepAlive

3. TCP KeepAlive vs. HTTP KeepAlive

  • They are unrelated.
    • TCP KeepAlive is a liveness mechanism that sends heartbeat packets to detect whether the other endpoint is still alive.
    • HTTP Keep-Alive is used to negotiate reuse of a TCP connection.

4. HTTP Client Selection

  • Server side: Apache HttpComponents (an upgraded version of Apache HTTP Client).
  • Android: OkHttp (supports HTTP/2).

5. References

Discussion

Sign in with GitHub to comment. Discussions are stored as GitHub Issues.View on GitHub