HTTP/2 Features
HTTP/2 kept the semantics of HTTP/1.1 — methods, headers, status codes — and replaced the wire format with a binary, multiplexed framing layer.
Binary framing
HTTP/2 messages are split into binary frames carrying typed payloads. The wire format is no longer human-readable, but it's much cheaper for software to parse and produces less ambiguity than the textual HTTP/1.1 grammar.
Streams and multiplexing
A single TCP connection carries many concurrent "streams" — independent request/response pairs. Frames from different streams are interleaved on the wire. This eliminates the head-of-line blocking that plagued HTTP/1.1 pipelining and removes the need for browsers to open six connections per origin.
HPACK header compression
Headers repeat heavily (think Cookie, User-Agent) so HTTP/2 ships HPACK — a Huffman-coded compression scheme with a static and dynamic table. Typical bandwidth savings on header traffic: 70–90%.
Prioritization
Clients can hint relative priority and dependencies between streams. Servers schedule frame transmission accordingly. In practice, the original priority spec was complex; RFC 9218 introduces a simpler model.
Server push
The server can preemptively send resources the client will need. Sounded good; in practice didn't work well — browsers couldn't tell if the client already had the resource cached. Chrome removed support in 2022. Use 103 Early Hints with Link: rel=preload instead.
Adoption notes
- All major browsers require TLS to negotiate HTTP/2 (
h2via ALPN). Cleartext HTTP/2 (h2c) exists but is rare outside service mesh. - HTTP/2 makes some HTTP/1.1 hacks counterproductive: domain sharding and concatenating CSS files often hurt performance under HTTP/2.
- One TCP connection means one TCP head-of-line problem at the transport layer — addressed by HTTP/3 over QUIC.