HTTP/1.1, HTTP/2 and HTTP/3
AdvancedThe same page loaded three ways: many connections in HTTP/1.1, one shared connection in HTTP/2, and QUIC in HTTP/3, where one lost packet no longer stalls everything.Builds on How HTTPS keeps a connection private
$ curl -sI --http1.1 https://example.com/ | head -1HTTP/1.1 200 OK $ curl -sI --http2 https://example.com/ | head -1HTTP/2 200 $ curl -sI --http3 https://example.com/ | head -1HTTP/3 200 $ curl -sI https://example.com/ | grep -i alt-svcalt-svc: h3=":443"; ma=86400 $ curl -v https://example.com/ 2>&1 | grep ALPN* ALPN: curl offers h2,http/1.1* ALPN: server accepted h2Empty
Spaceplay or pause←→previous or next stepRback to the start
Explanation
3 min read
On this page
What changed between HTTP/1.1, HTTP/2 and HTTP/3?
All three versions speak the same language: the same methods, status codes and headers. What changed is how the messages travel.
- HTTP/1.1 (1997) sends requests as text. A connection carries one response at a time, so browsers open up to six connections per site, each paying for its own handshake.
- HTTP/2 (2015) cuts messages into binary frames and sends many requests at once over one connection, as interleaved . It also compresses repeated headers.
- HTTP/3 (2022) keeps the streams but replaces TCP with QUIC, a transport built on UDP with TLS inside it. Connecting takes one round trip, and a lost packet only delays its own stream.
How do HTTP/2 and HTTP/3 make a page load faster?
- Multiplexing. With HTTP/2, the stylesheet, scripts and images all start at once on the same connection, instead of queueing or opening new connections with new handshakes.
- Header compression. Requests to the same site repeat the same headers (cookies, user agent…). HTTP/2's HPACK and HTTP/3's QPACK send them once and then refer to them by number.
- Head-of-line blocking. TCP delivers bytes strictly in order, so in HTTP/2 a lost packet holds back every stream behind it. QUIC knows which stream each packet carries, so only that stream waits.
- Faster setup. TCP plus TLS 1.3 takes two round trips; QUIC does both in one, and a returning visitor can send the first request in the very first packet (0-RTT).
- Switching networks. A QUIC connection is identified by an ID, not by your IP address, so it can survive moving from Wi-Fi to mobile data.
- Finding HTTP/3. The browser learns that a site supports it from an
alt-svcheader, or from the site's DNS records, and falls back to HTTP/2 if UDP is blocked.
What do people get wrong about HTTP versions?
Mini example
curl -w prints how a transfer went. Here it shows the version used and how long the connection
and the encryption took (the times are an example):
# HTTP/2 over TCP: connect after one round trip, TLS after another$ curl -so /dev/null -w '%{http_version} tcp: %{time_connect}s tls: %{time_appconnect}s\n' https://example.com/2 tcp: 0.051s tls: 0.104s # HTTP/3 over QUIC: connection and encryption in one round trip$ curl -so /dev/null --http3 -w '%{http_version} tls: %{time_appconnect}s\n' https://example.com/3 tls: 0.053sQuick check
On HTTP/2, one TCP packet carrying part of a stylesheet is lost. What happens to the images downloading at the same time?
Further reading
All steps as text
- Step 1:
First, HTTP/1.1. Before the first request, the browser opens a TCP connection and secures it with TLS: two round trips, 100 ms here.
Lines 1–2
- Step 2:
Then index.html comes back on that connection. It mentions five more files: a stylesheet, a script and three images.
- Step 3:
An HTTP/1.1 connection carries one response at a time. style.css reuses the first one, and for the rest the browser opens more connections, each with its own handshake.
- Step 4:
Only then can the other four files come down, one per connection. The page has everything at 300 ms.
- Step 5:
Now HTTP/2. During the TLS handshake, the browser offers h2 and the server accepts it (ALPN), so choosing the version costs no extra trip.
Lines 13–15
- Step 6:
HTTP/2 sends all five requests at once on the same connection, as separate streams whose pieces are interleaved. No new handshakes: done at 210 ms.
Lines 4–5
- Step 7:
HTTP/2 has a weak spot on lossy networks like a busy phone signal. Same load again, but at 160 ms one TCP packet of style.css is lost.
- Step 8:
TCP hands bytes over strictly in order, so everything behind the lost packet waits for the resend, even the images’ data. Every stream stalls: head-of-line blocking.
- Step 9:
Once the packet is resent, all five streams finish together. One lost packet cost every file 50 ms: loaded at 250 ms.
- Step 10:
HTTP/3 runs on QUIC, over UDP. QUIC sets up the connection and the encryption together, in one round trip: 50 ms instead of 100.
Lines 7–8
- Step 11:
QUIC knows which stream each packet belongs to. When a packet of style.css is lost, only style.css waits; the other four files finish at 150 ms.
- Step 12:
With the stylesheet resent, the page is loaded at 160 ms, even with the lost packet. A visitor coming back can even send the first request with the handshake.
- Step 13:
How does the browser know a site speaks HTTP/3? The first visit uses HTTP/2, and its responses carry
alt-svc: h3. Next time the browser tries QUIC.Lines 10–11
- Step 14:
Same page, same files: HTTP/1.1 pays for many connections, HTTP/2 shares one but stalls on loss, and HTTP/3 keeps streams independent with a shorter handshake.