← All posts

Protocols

TLS 1.3 0-RTT: where we use it and where we refuse to

Early data can save a full round trip for returning visitors. It can also replay requests. How we decide which requests may use it, and the numbers from a year in production.

Protocols team4 min read

TLS 1.3 lets a returning client send application data in its very first flight, before the handshake completes. For a visitor in São Paulo talking to our edge, that is one round trip saved on every resumed connection, often 40 to 50 milliseconds. It sounds like free performance. It is not free: early data has no protection against replay, so anyone who captures that first flight can send it again.

The replay problem in practice

An attacker who records a 0-RTT request can resend it to the same or another edge location within the ticket's lifetime. The TLS layer cannot tell the copy from the original. For a GET of a stylesheet, that is harmless: the attacker gets a stylesheet. For a POST that places an order, it could place two orders. The question is never whether 0-RTT is safe in general, but which requests are safe to accept early.

Our rules

We accept early data only when every one of these conditions holds:

  • The method is GET or HEAD, and the request has no body.
  • The total early data is at most 16 KB, which fits any reasonable request line and headers.
  • The request would be answered from cache, or the cache rule for the path marks the origin as idempotent.
  • The site has not disabled early data, which customers can do per site or per path.

Anything else is held until the handshake completes, which costs the visitor nothing compared with not supporting 0-RTT at all. If a request has already reached our HTTP layer as early data and turns out to need forwarding to an origin that is not marked idempotent, we answer 425 Too Early, as defined in RFC 8470, and the browser retries automatically after the handshake.

Request and response
GET /account/orders HTTP/2
host: www.example.com
early-data: 1

HTTP/2 425
content-type: text/plain
cache-status: cachebz; fwd=bypass; detail=early-data-rejected

Limiting replay across locations

Within a single location, we keep a short-lived record of early-data client hellos and reject duplicates. Across locations that is not practical without a global round trip, which would defeat the purpose. Instead, session tickets are bound to the region that issued them: a ticket from our Frankfurt servers is only accepted for 0-RTT in central Europe. A replayed ticket sent to Tokyo still resumes the session, just without early data. Ticket keys rotate every hour and expire after 24 hours.

Telling the origin

When an accepted early-data request is forwarded to an origin, we add the Early-Data: 1 header. Origins that understand it can answer 425 themselves for anything they consider unsafe. Most frameworks ignore the header, which is why our defaults do not forward early data to origins unless a customer explicitly opts in.

cachebz.toml
[site.tls]
early_data = true

# 0-RTT is only honoured for these; everything else waits for the handshake
early_data_allow = { methods = ["GET", "HEAD"], max_bytes = 16384 }

The numbers

A year after enabling 0-RTT for cacheable requests by default, 22% of all TLS connections to our edge are resumptions, and 71% of those carry early data. The saving is largest exactly where latency hurts most:

Connection typeRound trips to first byteMedian TTFB, South America
New connection, TLS 1.3 full handshake2 RTT98 ms
Resumed, 1-RTT2 RTT97 ms
Resumed with 0-RTT1 RTT51 ms
HTTP/3, resumed with 0-RTT1 RTT47 ms

We have seen no replay-related incidents in that time. Our security team runs a weekly test that captures and replays early data against staging edges in three regions, and the replays are rejected or downgraded as designed.

Should you turn it off?

For most sites, no. Our defaults only accept early data for requests where a replay has no effect. If your application does something unusual on GET, such as logging out a user or redeeming a one-time link, either mark those paths with early_data = false or, better, make those actions use POST. The same principle of being conservative at the edge runs through everything we build.

Questions or corrections? Write to the engineering team at hello@cache.bz. We read everything and update posts when we get something wrong.