Connection Establishment

Connection establishment is the sequence of network operations that must complete before a browser can exchange application data with an origin. For a typical HTTPS request, this can involve DNS resolution, a transport connection, and a TLS handshake.

A browser first needs to determine where the origin is reachable. DNS resolution maps a hostname such as `example.com` to an address, though the result may already be available from browser, operating-system, or other caches.

The browser then establishes a transport connection. With TCP-based HTTP/1.1 or HTTP/2, this normally includes a TCP three-way handshake before application bytes can flow. HTTP/3 uses QUIC over UDP instead, combining transport and TLS functionality differently.

For HTTPS, TLS establishes encryption and authenticates the server before protected HTTP data is exchanged. A TLS handshake can require several network round trips depending on the protocol version, connection state, and whether the connection can be resumed.

Connection establishment matters to frontend performance because latency spent before the first request byte is independent of the time required for the server to generate the response. Reusing an existing connection, caching DNS information, and using protocols with fewer setup round trips can reduce this overhead.

Key points

Interview questions

What steps happen before an HTTPS request can send application data?

The browser first needs to resolve the hostname, unless it already has a usable cached result. For traditional TCP-based HTTPS, it then establishes a TCP connection. TLS negotiation follows so the parties can authenticate and establish encryption keys. After that, the browser can send the protected HTTP request.

Why can reusing a connection improve frontend performance?

A newly created connection can require DNS lookup, transport setup, and TLS negotiation before useful HTTP data is exchanged. If an existing connection remains usable, those setup steps do not need to be repeated for every request. This reduces latency, particularly when network round-trip time is significant. Connection reuse is therefore an important part of optimizing repeated requests to the same origin.

How does HTTP/3 change connection establishment compared with HTTP/2?

HTTP/2 commonly runs over TCP with TLS, so transport establishment and TLS negotiation occur over that stack. HTTP/3 uses QUIC, which runs over UDP and incorporates TLS 1.3 into the QUIC connection setup. This changes the handshake and transport behavior rather than simply removing TLS. QUIC also provides stream multiplexing without relying on TCP's transport-level ordering.

What factors determine how much latency connection establishment adds?

The number of network round trips is a major factor, so physical distance and network conditions matter. DNS cache state, whether a connection already exists, and whether TLS can be resumed also affect the amount of setup work. The protocol in use matters as well because TCP-based HTTPS and QUIC have different connection procedures. Therefore, there is no single fixed connection-establishment latency for every request.