Catalog My learning Blog
Computer Networking for Developers: TCP, DNS, HTTP, TLS · Phase 2 · Lesson 14 · 4 min read

HTTP/2 vs HTTP/3 and QUIC Explained

On this page
  1. HTTP/1.1, HTTP/2 and HTTP/3: one problem
  2. HTTP/2: many streams, one connection
  3. TCP head-of-line blocking in HTTP/2
  4. HTTP/3: QUIC over UDP
  5. Checking the HTTP version with curl and ALPN
  6. Enabling HTTP/2 and HTTP/3
  7. Check yourself

HTTP/1.1, HTTP/2 and HTTP/3: one problem

HTTP/1.1 handles one request at a time per connection, so a slow response blocks the ones behind it: head-of-line blocking at the application layer. Browsers open six connections per host to cope. HTTP/2 and HTTP/3 each attack this problem at a different layer.

HTTP/2: many streams, one connection

HTTP/2 (2015) keeps HTTP's meaning (methods, headers, status codes) but changes the wire format:

  • Binary framing: messages are split into frames tagged with a stream id.
  • Multiplexing: many requests and responses share one connection, their frames interleaved. A slow response no longer blocks others.
  • Header compression (HPACK): repeated headers like cookies and user agents are sent once and referenced afterwards.
  • One connection per host, so one TCP and TLS handshake, and one congestion window that grows to full speed.

Server push was also part of the spec, but browsers have removed support for it; use 103 Early Hints or preload links instead.

TCP head-of-line blocking in HTTP/2

All those streams share one TCP connection, and TCP delivers bytes strictly in order (Day 8). If one packet is lost, every stream waits for its retransmission, even streams whose data already arrived. On a lossy mobile network, HTTP/2 can do worse than several HTTP/1.1 connections.

HTTP/1.1 blocking per request, HTTP/2 multiplexed streams stalled together by one lost TCP segment, and HTTP/3's QUIC streams continuing independently.
HTTP/1.1 blocking per request, HTTP/2 multiplexed streams stalled together by one lost TCP segment, and HTTP/3's QUIC streams continuing independently.

HTTP/3: QUIC over UDP

HTTP/3 (2022) runs on QUIC, a transport built on UDP (Day 10):

  • Independent streams: QUIC tracks loss per stream. A lost packet only stalls the stream it belongs to.
  • Faster setup: QUIC combines the transport and TLS 1.3 handshakes into one round trip, and can send data in the very first flight (0-RTT) when resuming a previous connection. 0-RTT data can be replayed by an attacker, so servers only accept it for safe requests.
  • Connection migration: connections are identified by an id, not the IP and port, so a phone switching from Wi-Fi to cellular keeps its connection.
  • Always encrypted: even most transport headers are encrypted, so middleboxes can't tamper with them.

Checking the HTTP version with curl and ALPN

Browsers discover HTTP/2 during the TLS handshake through ALPN (Application-Layer Protocol Negotiation). They learn HTTP/3 exists from an alt-svc header (or a DNS HTTPS record) and use it on later connections.

Shell
curl -sv --http2 https://example.com/ -o /dev/null 2>&1 | grep -E 'ALPN|using HTTP|^< HTTP'
curl -sI https://www.google.com/ | grep -iE '^(HTTP|alt-svc)'
Code
* ALPN: curl offers h2,http/1.1
* ALPN: server accepted h2
* using HTTP/2
< HTTP/2 200
HTTP/2 200
alt-svc: h3=":443"; ma=2592000,h3-29=":443"; ma=2592000

The server accepted h2 through ALPN, and Google advertises HTTP/3 (h3) on UDP port 443, cached for 30 days (ma is max age in seconds). To test HTTP/3 itself, use a curl built with HTTP/3 support (curl --http3); the stock macOS curl lacks it. In browser DevTools, add the Protocol column to the Network tab.

Enabling HTTP/2 and HTTP/3

  • Enable HTTP/2 and HTTP/3 at your CDN or load balancer. Most support both; HTTP/3 needs UDP 443 open through firewalls.
  • Undo HTTP/1.1 workarounds that hurt under HTTP/2: domain sharding (splitting assets across hostnames) defeats single-connection multiplexing.
  • Clients fall back: if UDP is blocked, browsers keep using HTTP/2 over TCP, so offering HTTP/3 is low risk.

Check yourself

It removes blocking between requests at the HTTP level through multiplexing, but all streams still share one TCP connection, so a lost packet stalls them all.

It tracks delivery and ordering separately per stream over UDP. A lost packet only delays the stream whose data it carried, while other streams keep delivering, whereas TCP holds back every stream until the lost segment is retransmitted.

Through an alt-svc response header advertising h3 on a port, or a DNS HTTPS record. The browser then tries QUIC on later connections, falling back to TCP if UDP is blocked.

It combines the transport and TLS 1.3 handshakes into one round trip, supports 0-RTT resumption, and lets connections survive a network change, like Wi-Fi to cellular.

Some corporate and public networks block or throttle UDP, so QUIC connections fail or perform poorly. Browsers detect this and fall back to HTTP/2 over TCP, so sites must keep supporting both.