HTTP/2 and HTTP/3
The same semantics, different bytes — and what to actually do.
Methods, status codes and headers are unchanged. Only the bytes differ.
What stayed the same
One URL, either version, same status:
curl -sk --http2 -o /dev/null -w 'http2 -> %{http_version}\n' \
https://localhost:8443/
curl -sk --http1.1 -o /dev/null -w 'http1.1 -> %{http_version}\n' \
https://localhost:8443/Chapters 3 to 9 still apply unchanged.
Binary framing
HTTP/1.1 was text you could type. This is not:
curl -skv --http2 https://localhost:8443/ -o /dev/null 2>&1 \
| grep 'OPENED stream'Lowercase headers
The wire format normalises header names:
curl -skv --http2 https://localhost:8443/ -o /dev/null 2>&1 \
| grep -E '^< (HTTP|server|content)'Without the < markers:
curl -skI --http2 https://localhost:8443/ | head -2Two differences from chapter 2: names arrive lowercase, and the status line has no reason phrase. Side by side:
curl -skv --http1.1 https://localhost:8443/ -o /dev/null 2>&1 | grep '^< HTTP'
curl -skv --http2 https://localhost:8443/ -o /dev/null 2>&1 | grep '^< HTTP'Streams
Each request is a numbered stream; many share one connection:
curl -skv --http2 https://localhost:8443/ https://localhost:8443/ \
-o /dev/null -o /dev/null 2>&1 | grep -c 'OPENED stream'curl counts one connection for both:
curl -sk --http2 -o /dev/null -o /dev/null \
-w 'connects=%{num_connects}\n' \
https://localhost:8443/ https://localhost:8443/Two streams, one connection, no ordering between them — the fix for chapter 7’s head-of-line blocking.
The six-connection workaround becomes unnecessary, and so does bundling to dodge it.
Negotiating it
ALPN picks the version inside the TLS handshake — chapter 10:
curl -skv --http2 https://localhost:8443/ -o /dev/null 2>&1 \
| grep -E 'ALPN|using HTTP'HPACK
Headers compress against a table both sides keep, so a repeated one costs almost nothing. A large cookie stops being expensive.
It is per-connection state, which made HTTP/2 implementations a source of memory-exhaustion bugs.
Server push
The server could send a response nobody asked for. Chrome removed it in 2022 and the others followed.
It lost to <link rel="preload">, which lets the client decide. Push in a tutorial means
the tutorial predates 2022.
HTTP/3 and QUIC
Same semantics again, over UDP. This curl cannot speak it:
curl --http3 https://example.com/ 2>&1 | head -1The macOS build ships without QUIC, so this section has no transcript.
TCP recovers lost packets in order, so one loss stalls every stream — head-of-line blocking moved down a layer rather than vanishing. QUIC makes each stream independent.
A server advertises it in a header:
{ printf 'HTTP/1.1 200 OK\r\n'
printf 'Alt-Svc: h3=":443"; ma=86400\r\n'
printf 'Content-Length: 0\r\n\r\n'
} | nc -l 9000 >/dev/null &
curl -sI localhost:9000/ | grep -i alt-svcAlt-Svc tells the client to try HTTP/3 next time.
What to actually do
Almost nothing. Turn it on at the edge, change no application code:
| Practice | Under HTTP/2 |
|---|---|
| Bundling every asset | mostly unnecessary |
| Domain sharding | actively harmful — it splits the connection |
| Inlining images as data URIs | unnecessary |
| Six-connection workarounds | obsolete |