HTTP/2: Multiplexing, header compression and server push
In short: HTTP/2 transmits many requests simultaneously over a single connection and compresses headers, making web pages faster than HTTP/1.1.
In more detail: HTTP/1.1 handles one request after another per connection; browsers therefore open several connections and struggle with head-of-line blocking (one slow response holds up everything behind it). HTTP/2 (2015) solves many of these problems without changing the meaning of methods, status codes and headers.
In Depth
Key innovations
- Binary protocol instead of text: more compact and faster to process.
- Multiplexing: many streams run in parallel over one TCP connection; frames of different requests are interleaved.
- Header compression (HPACK): recurring headers (cookies, user agent) are sent in full only once.
- Prioritisation of streams.
- Server push: server sends resources ahead unasked (barely used in practice and removed by browsers).
Consequences for web development
It used to help to bundle many small files (sprites, concatenation) and spread them across several domains (domain sharding). With HTTP/2 this is often unnecessary or harmful; many small files are no longer a big problem, though bundling remains sensible to reduce overhead and for caching. Browsers use HTTP/2 only over HTTPS.
Limits and successor
HTTP/2 runs over TCP: if a packet is lost, the whole connection waits (head-of-line blocking at TCP level). HTTP/3 relies on QUIC (over UDP), independent per stream, with faster connection set-up and connection migration (Wi-Fi to mobile). Servers announce HTTP/3 availability via Alt-Svc.
Checking
In the browser under F12 → Network look at the Protocol column (h2, h3). In the terminal: curl -I --http2 https://example.com. Web servers such as Nginx, Caddy and Apache enable HTTP/2 with one line of configuration, CDNs offer it automatically.
See also: QUIC and HTTP/3, HTTP keep-alive, HTTP headers, TLS