HTTP/1.1, 2, and 3: how each version loads the same page of 12 images

2025/04/30
networkhttpquictls

A product page has 12 images, and the server takes 300 ms to send each one. Loaded in Chrome 156 with the server and browser on the same machine, so the network RTT is almost 0: over HTTP/1.1 the page took about 630 ms, over HTTP/2 about 320 ms. Same 12 images, same server. Why is one twice as fast?

Move to a phone on a weak signal, and one lost packet on the way makes all 12 HTTP/2 images stop and wait together. The HTTP/3 spec names this problem in its introduction, and HTTP/3's answer is to replace the TCP underneath with QUIC.


What a connection, an RTT, and a handshake are

Before a browser can talk to a server, it has to set up a TCP connection. TCP guarantees that data arrives complete and in order, and HTTP requests and responses travel over that connection. HTTPS adds a layer of TLS encryption on top of TCP.

Data crosses the network in small pieces called packets. One image may take dozens of packets.

RTT (round trip time) is the time for one packet to go from the browser to the server, plus one packet to come back. It measures how long the browser sits waiting, not how many packets were sent.

client → server    there
server → client    back
together = 1 RTT

A handshake is the back-and-forth both sides do before any data is sent. The TCP three-way handshake has three packets but costs only 1 RTT:

client → server:  SYN
server → client:  SYN-ACK       ← 1 RTT of waiting ends here
client → server:  ACK + data    ← goes out with the next data, no extra wait

The third packet doesn't wait for any reply. The client sends it and starts sending data at the same time. Three packets, one round trip of waiting.

With HTTPS, a TLS handshake follows the TCP handshake: 1 more RTT for TLS 1.3, 2 for TLS 1.2.


HTTP/1.0: a new connection for every image

According to MDN, HTTP/1.0 closes the connection after each request by default, and the next request opens a new one. 12 images means 12 TCP handshakes, each waiting 1 RTT before the request can go out.

Some browsers and servers at the time supported Connection: keep-alive to keep the connection open, but RFC 9112 Appendix C.2.2 notes that this was an extension outside the HTTP/1.0 spec, and implementations differed.


HTTP/1.1: keep the connection, but one request at a time

HTTP/1.1 makes connections persistent by default: under RFC 9112 §9.3, unless Connection: close is sent, the connection stays open after the response. The 12 images can share one connection without a new handshake each.

But on that one connection, requests still go one after another. Until image 1's response finishes, image 2's request waits.

Head-of-line blocking

HTTP/1.1 has a feature called pipelining: send several requests without waiting for responses. But RFC 9112 §9.3.2 requires the server to send responses in the order the requests arrived. If image 1 is large, or the server is slow to produce it, images 2 and 3 wait for it to finish even if they were ready long ago:

Requests:   [img1] [img2] [img3] →
Responses:  [img1......] [img2] [img3]
                 ↑
     img2 and img3 wait for img1

The request at the front of the line holds up everything behind it. This is called head-of-line blocking.

No major browser turns pipelining on by default. MDN's reason is that many proxies handle pipelining with bugs, and when it fails, developers have a hard time finding out why. So in practice, each HTTP/1.1 connection carries one request and one response at a time.

The browser's workaround: 6 connections per host at once

If one connection can load only one image at a time, the browser opens several. Chrome uses at most 6 connections per host at the same time (g_max_sockets_per_group in Chromium's client_socket_pool_manager.cc), and Firefox's default is also 6 (network.http.max-persistent-connections-per-server).

When the product page from the start loads over HTTP/1.1, the server receives the requests at roughly these times:

0 ms      requests for img1–img6 arrive together (6 connections)
300 ms    img1–img6 finish
300 ms    requests for img7–img12 arrive
600 ms    img7–img12 finish
ProtocolImages in flight at oncePage load (runs 2 to 5 of 5)
HTTP/1.16626–634 ms
HTTP/212319–325 ms

The 12 images go in two batches, so HTTP/1.1 takes about twice as long.

The limit of 6 counts separately for each host. So some sites spread images across subdomains like img1.example.com and img2.example.com to get more connections. This is called domain sharding.


HTTP/2: all 12 images on one connection

In 2015 the IETF published HTTP/2 (RFC 7540) based on Google's SPDY, revised in 2022 as RFC 9113.

Streams and frames

The main change in HTTP/2 is multiplexing: one TCP connection carries many streams at once, and each stream is one request and its response. The 12 images become 12 streams on the same connection, with no line to wait in.

HTTP/1.1:  [img1][img1][img1][img2][img2][img3][img3]   ← one image finishes before the next starts
HTTP/2:    [img1][img2][img3][img1][img2][img3][img1]   ← interleaved

To interleave, HTTP/2 splits each message into smaller frames. Each frame is labeled with the stream it belongs to (the stream ID), and the receiver uses the stream ID to put the frames back together. One packet that TCP sends (TCP calls it a segment) can carry frames from three streams:

TCP segment 1: [img1 frame 1] [img2 frame 1] [img3 frame 1]
TCP segment 2: [img2 frame 2] [img2 frame 3]
TCP segment 3: [img1 frame 2] [img2 frame 4] [img3 frame 2]

Frames within one stream stay in order. Across streams there is no order, so image 2 doesn't wait for image 1 to finish.

When the product page loads over HTTP/2, the server sees 1 connection. All 12 requests arrive less than 5 ms apart, and all finish 300 ms later: the 320 ms in the table above.

One connection is enough

RFC 9113 §9.1 says a client should not open more than one HTTP/2 connection to the same host and port. Domain sharding from the HTTP/1.1 days now hurts: each extra subdomain costs another TCP and TLS handshake, and the header compression table described below is kept separately for each connection, so once the connections are split, the same cookie has to be sent in full on every connection.

Header compression (HPACK)

HTTP/1.1 compresses bodies (Content-Encoding: gzip), but headers are plain text. Every one of the 12 image requests carries the same User-Agent and Cookie.

HTTP/2 compresses headers with HPACK, the format RFC 7541 defines. It has two tables:

  • Static table: 61 common headers fixed in the spec. Index 2 is :method GET, index 4 is :path /.
  • Dynamic table: headers already sent on this connection, which §2.3.3 numbers from 62.

When the next request sends the same header, it sends only the index. Two requests encoded with Go's x/net/http2/hpack, with a 2008-byte cookie in the headers:

Bytes
The same headers as HTTP/1.1 plain text2173 per request
HPACK, request 1 (/img/1.jpg)1702
HPACK, request 2 (/img/2.jpg)15

In request 2, the 2008-byte cookie takes 1 byte.

Server Push: now turned off

HTTP/2 let the server push resources before the browser asked. The browser requests index.html, and the server sends style.css and app.js along with it.

In theory this saves some round trips. But the server doesn't know what is already in the browser's cache, so, as Jake Archibald describes, it often pushed files the browser already had. The analyses the Chrome team cited when announcing push's removal measured no clear speedup either, and many cases got slower. Chrome 106 (2022) turned push off by default, and Firefox 132 (2024) did too.

The replacement is 103 Early Hints, the status code RFC 8297 defines. The server doesn't push files. It first sends a 103 that tells the browser which files it will probably need. According to Chrome's docs, the browser decides whether to fetch them, skipping the ones already in its cache. curl against www.cloudflare.com receives an HTTP/2 103 before the 200.

ALPN: picking the protocol during the TLS handshake

TLS has an extension called ALPN (Application-Layer Protocol Negotiation, RFC 7301), which the browser uses to tell the server it wants HTTP/2. During the TLS handshake, the client lists the protocols it supports, and the server picks one in its reply, with no extra round trip. curl against www.cloudflare.com:

$ curl -v --http2 https://www.cloudflare.com/
* ALPN: curl offers h2,http/1.1
* ALPN: server accepted h2
> GET / HTTP/2

The spec also allows unencrypted HTTP/2 (h2c), but Chrome 156 against a local h2c server only returns ERR_INVALID_HTTP_RESPONSE, so in a browser, HTTP/2 always runs over HTTPS.


HTTP/2 on a lossy network: all 12 images wait

When a phone or Wi-Fi signal is weak, some packets get lost on the way, and TCP resends them once it notices.

According to RFC 9293, TCP guarantees that data is handed to the layer above in order. So if one packet is missing, the packets after it that already arrived are held back until the lost packet is resent and arrives, and only then all go to HTTP/2 together.

Back to the 12 images. Suppose the packet carrying frame 3 of image 1 is lost:

img1: [frame 1] [frame 2] [frame 3 lost] [frame 4]
img2: [frame 1] [frame 2] ← already arrived, but waiting for img1's frame 3 to be resent
img3: [frame 1]           ← also waiting

The data for images 2 and 3 arrived long ago, but because TCP hands data over in order, they have to wait too. HTTP/2 removed head-of-line blocking at the HTTP layer, but TCP has its own at the layer below.

With HTTP/1.1's 6 connections, one lost packet affects only the connection it was on, and the other 5 carry on. HTTP/2 has one connection, so all 12 images stop. Whether the whole page then loads slower than over HTTP/1.1 on a lossy network: studies disagree, and it was not measured here.


HTTP/3: replace TCP with QUIC

TCP's head-of-line blocking comes from TCP's own design of handing data over in order, so removing it means replacing TCP. QUIC is a transport protocol that runs on UDP. Google built it first, then handed it to the IETF for standardization, which published it in 2021 as RFC 9000. HTTP/3 is HTTP running on QUIC, published in 2022 as RFC 9114.

UDP itself guarantees neither delivery nor order, so QUIC adds resending, ordering, and congestion control (adjusting how fast to send based on how congested the network is). Unlike TCP, QUIC orders data per stream. Under RFC 9000 §13, when a packet is lost, only the streams with data in that packet wait for the resend, and the other streams keep going.

The same loss of image 1's frame 3, over HTTP/3:

img1: [frame 1] [frame 2] [frame 3 lost] [frame 4]  ← img1 waits for the resend
img2: [frame 1] [frame 2]                        ← handed over as usual
img3: [frame 1]                                  ← handed over as usual

Some things QUIC did not make per stream:

  • One QUIC packet can carry data from several streams. If that packet is lost, all of those streams wait (RFC 9000 §13).
  • Under RFC 9002, congestion control is still one per connection.
  • Smashing Magazine points out that when loading a real web page, browsers often let a few streams finish first, so not many streams run at once, and removing head-of-line blocking helps less than in theory.

Header compression changed too. In HPACK, image 2's request uses an index for the cookie, and that index was assigned when image 1's request added the cookie to the dynamic table. TCP guarantees image 1's headers arrive first, so this works. But as RFC 9204 §1 explains, on QUIC, if the packet carrying image 1's headers is lost, image 2's headers arrive first, the server can't look up what that index is, and it has to wait for image 1's packet to be resent: head-of-line blocking again. So HTTP/3 replaces HPACK with QPACK.

What QUIC changes

Problem with TCPWhat QUIC does
One lost packet makes every stream waitOnly the streams in that packet wait
TCP handshake plus TLS handshake takes 2 to 3 RTTRFC 9001 merges both handshakes into 1 RTT
When the IP changes (Wi-Fi to 4G), the connection breaksRFC 9000 §9 identifies connections by connection ID, so a client can change IP and keep going
Devices on the path (firewalls, NAT) read TCP headers and depend on their format, which makes TCP hard to changeMost of the QUIC header is encrypted, so devices on the path can't depend on it

How the browser learns a server has HTTP/3

On the first visit, the browser doesn't know whether the site has HTTP/3, so it usually goes over TCP. Under RFC 9114 §3.1.1, the server includes an Alt-Svc header in its response, and the browser switches to QUIC next time. curl against www.cloudflare.com receives:

alt-svc: h3=":443"; ma=86400

If the network blocks UDP and QUIC can't connect, the browser falls back to HTTP/2 or HTTP/1.1 over TCP.


How many RTTs before the first byte

Round trips before the first byte, added up from the specs:

ScenarioTCPTLSRequestTotal
HTTP/1.1, unencrypted1012 RTT
HTTP/2 + TLS 1.21214 RTT
HTTP/2 + TLS 1.31113 RTT
HTTP/2 + TLS 1.3 0-RTT (connected before)1012 RTT
HTTP/3, first connection—1 (merged with QUIC)12 RTT
HTTP/3 0-RTT (connected before)—011 RTT

Measured on a local machine with Go against www.google.com/generate_204, 20 times each (this URL returns an empty 204, so the server spends almost no time). HTTP/3 uses quic-go v0.59.0. DNS is resolved before the timer starts, and all four cases connect straight to that IP, so none of the times below include DNS:

ScenarioFirst byte, median
TCP connect only (= 1 RTT)21.9 ms
HTTP/2 + TLS 1.392.0 ms
HTTP/3, first connection62.1 ms
HTTP/3 0-RTT34.5 ms

Going from HTTP/2 to HTTP/3's first connection saves 29.9 ms, and going on to 0-RTT saves another 27.6 ms; each step is a little more than one RTT (21.9 ms).

What 0-RTT means

0-RTT doesn't mean no round trip at all. A client that has connected to this server before keeps the session ticket the server gave it. On the next connection it uses that ticket to derive keys, and its very first packet already carries the encrypted request. The TLS handshake adds no RTT, and the whole exchange from sending the request to getting the response takes 1 RTT.

HTTP/2 over TLS 1.3 can also do 0-RTT, but it still needs the TCP handshake first, 1 more RTT. QUIC merges the connection handshake with the TLS handshake, so it saves that trip.

0-RTT has two limits:

  • RFC 9001 §9.2 warns that an attacker can record 0-RTT data and replay it, so it suits only requests that are safe to repeat, such as GET.
  • The server can refuse it. In the measurement above, www.google.com used 0-RTT on all 20 connections.

The whole chain

HTTP/1.0  →  a new TCP connection per request, a handshake every time
    ↓ keep connections open and reuse them
HTTP/1.1  →  one request at a time per connection; a slow one makes the rest wait (head-of-line blocking)
    ↓ many streams at once on one connection
HTTP/2    →  one lost TCP packet makes every stream wait
    ↓ replace TCP with QUIC (UDP plus per-stream ordering)
HTTP/3    →  2 RTT on first connection, 1 RTT when connected before

Environment

ItemVersion
OSmacOS 15 (Darwin 24.6.0), Apple Silicon
Chrome156.0.8078.79, headless, puppeteer-core 25
Node.js22.22.3
Go1.26.1, golang.org/x/net v0.53.0, github.com/quic-go/quic-go v0.59.0
curl8.7.1 (macOS built-in, no HTTP/3)
OpenSSL3.6.3

The 12-image page: Node.js https and http2 servers on 127.0.0.1, each image held 300 ms before the server replies, 5 runs. Run 1 includes Chrome's cold start, so the table uses runs 2 to 5.


References