keepcalculator

06 Numbers and Powers

What Happens After You Press Enter: HTTP’s 7 Decisions

Card No. 06·82066 · Updated · Standard formula, shown below

When you press Enter after typing a URL, your browser and the server make seven key decisions that determine whether and how the page loads. These decisions cover everything from translating the domain name to an IP address, to establishing a secure connection, to fetching and rendering the final content. This article walks through each step in plain language, with the technical details you need to understand what’s happening behind the scenes.

Decision 1: DNS Resolution — Finding the Server’s Address

The first decision is translating the human-readable domain (like example.com) into a numeric IP address. Your browser checks its own cache, then your operating system’s cache, then your router’s cache, and finally queries a DNS resolver (usually your ISP’s). If no cache has the answer, the resolver performs a recursive query, starting at the root DNS servers and following referrals down to the authoritative name server for that domain. That server returns the IP address, often with a TTL (time-to-live) value that tells resolvers how long to cache it.

This decision matters because every subsequent connection uses that IP. If DNS fails (e.g., the domain is misspelled or the server is down), you get a “server not found” error. The entire process typically takes milliseconds, but it can be slower if the domain has a long chain of CNAME records or if the resolver is overloaded.

Decision 2: TCP Connection — Establishing a Reliable Channel

With the IP address in hand, your browser opens a TCP connection to the server on port 80 (for HTTP) or port 443 (for HTTPS). This uses the three-way handshake: SYN, SYN-ACK, ACK. The handshake ensures both sides are ready to send and receive data. If the server is busy or unreachable, the connection times out and you see an error.

Modern browsers often reuse existing connections via keep-alive, and they may open multiple parallel connections (usually 6 per host) to speed up loading. But for a single request, the handshake is a required step—and it’s one of the reasons HTTPS feels slower than HTTP on first load (more on that later).

Decision 3: TLS Handshake (if HTTPS) — Encrypting the Conversation

If the URL starts with https://, the browser and server perform a TLS handshake before any HTTP data is sent. This involves several sub-decisions:

  • Protocol version: Both sides agree on the highest TLS version they both support (e.g., TLS 1.3).
  • Cipher suite: They pick an encryption algorithm and a key exchange method (e.g., AES-GCM with ECDHE).
  • Certificate verification: The server sends its certificate, and the browser checks it against trusted root CAs, verifies the domain name matches, and checks the expiration date.

If any of these fail—like an expired certificate or a mismatch—the browser shows a warning page. If they succeed, both sides derive session keys and all subsequent data is encrypted.

Decision 4: HTTP Request — Sending the Method and Headers

Now the browser sends the actual HTTP request. The first line includes the method (GET, POST, etc.), the path (like /index.html), and the HTTP version. Then come headers: Host, User-Agent, Accept, Cookie, and more. The server uses these to decide how to respond.

The Host header is crucial because a single server can host many websites (virtual hosting). Without it, the server wouldn’t know which site you want. The Accept header tells the server what content types you can handle (e.g., HTML, JSON, images). Cookies carry session state, so the server knows who you are.

Decision 5: Server Processing — Routing and Generating the Response

The server receives the request and decides how to handle it. This could involve:

  • Static files: If the path matches a file on disk (like /css/style.css), the server returns it directly.
  • Dynamic content: If the path maps to an application (like a PHP script or a Node.js route), the server executes code, queries databases, and generates HTML on the fly.
  • Redirects: The server may respond with a 301 or 302 status code, telling the browser to go to a different URL (e.g., from http:// to https://).

This is where most of the “thinking” happens. The server’s decisions affect response time and content. A well-optimized server might cache responses, use a CDN, or load-balance across multiple machines.

Decision 6: Response and Status Code — Interpreting the Result

The server sends back a response with a status code, headers, and a body. The status code tells the browser what happened:

  • 2xx: Success (e.g., 200 OK).
  • 3xx: Redirection (e.g., 301 Moved Permanently).
  • 4xx: Client error (e.g., 404 Not Found).
  • 5xx: Server error (e.g., 500 Internal Server Error).

The response headers include Content-Type (what the body is), Content-Length, Cache-Control, Set-Cookie, and more. The browser uses these to decide how to handle the body: render it as HTML, save it as a file, or display an error page.

Decision 7: Rendering — Parsing, Building, and Painting

If the response is HTML, the browser begins the rendering pipeline. It parses the HTML to build the DOM (Document Object Model), then parses CSS to build the CSSOM (CSS Object Model). These are combined into a render tree, which is then laid out and painted to the screen. Along the way, the browser encounters additional resources (images, scripts, stylesheets) and makes more HTTP requests, repeating decisions 1–6 for each.

JavaScript can modify the DOM and CSSOM after parsing, which may trigger reflows and repaints. The browser also runs scripts that may block rendering, depending on whether they are async or defer. The final decision is when to display the page: typically, the browser shows content as soon as it has enough to paint, even if some resources are still loading.

Frequently Asked Questions

Why does HTTPS feel slower than HTTP?

HTTPS adds an extra TLS handshake, which involves several round trips between browser and server. With TLS 1.3, that’s reduced to one round trip, but it’s still more than HTTP’s zero. However, the security benefit outweighs the slight delay, and modern techniques like session resumption can eliminate the extra round trip on repeat visits.

What happens if the DNS server is down?

If your DNS resolver is unreachable, your browser can’t resolve the domain to an IP address, so you can’t connect. You might see an error like “ERR_NAME_NOT_RESOLVED”. You can try switching to a public DNS like 8.8.8.8 or 1.1.1.1, but that’s a manual configuration change.

Can a website load without all seven decisions?

No. Every decision is necessary. Even a cached page requires at least a DNS lookup (unless the IP is cached) and a TCP connection. Without DNS, you can’t find the server; without TCP, you can’t send data; without rendering, you can’t see the page.

Why do some pages load instantly while others take seconds?

The main factors are server response time, network latency, and the number of resources. A page with many images and scripts requires many requests, each with its own DNS, TCP, and possibly TLS handshakes. Browsers mitigate this with caching, keep-alive connections, and parallel loading, but the total time still depends on the server’s speed and the user’s bandwidth.

What is the most common failure point?

For everyday users, the most common failure is a 404 error (resource not found) or a DNS failure (typo in the URL). For developers, the most common issue is a misconfigured server that returns 500 errors. The best way to diagnose is to open the browser’s developer tools (F12) and look at the Network tab.

Does pressing Enter always trigger these seven decisions?

Yes, for a fresh request. But if the browser has the page cached and the cache is still valid (based on Cache-Control headers), it may skip the network entirely and render from cache. In that case, decisions 1–6 are skipped, and only the rendering step happens.

Related

Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.

More cards in this drawer

The whole Numbers and Powers drawer →