Skip to content
YouTurkey Tech
All web topics

What happens when you type a URL

Beginner

Everything between pressing Enter and the first byte of HTML: the browser cache, DNS, a secure connection, and an HTTP request and response.

Messages

Empty

0/13Press Play, or step through with the arrows, to begin.
Step 0 of 13

Explanation

3 min read

On this page

What happens when you type a URL?

The web is built on and servers. Your browser is a client: it asks for things. A server is a computer that waits for those requests and answers them. Typing a URL starts a short conversation between them, in four stops:

  1. Cache. The browser checks whether it already has a fresh copy of the page.
  2. DNS. It turns the name example.com into an IP address, the number computers use to find each other.
  3. Connection. It opens a TCP connection to that address and secures it with TLS.
  4. HTTP. It sends a request for the page and receives a response: a status, headers and the HTML. Then it starts building the page while the rest is still arriving.

How do DNS, HTTP and HTTPS work together?

  • DNS is the address book. A DNS resolver (run by your internet provider, or a public one like 1.1.1.1) looks up names for you. If it does not know a name, it asks the DNS servers responsible for it, then remembers the answer for a while, as your browser and operating system do.
  • HTTP is the language of the conversation. A request has a method and a path (GET /) and headers (Host, Accept…). A response has a status (200 OK, 404 Not Found, 301 Moved Permanently), headers (Content-Type, Cache-Control…) and a body. The lesson shows them as HTTP/1.1 text; HTTP/2 and HTTP/3, which browsers use for most sites today, carry the same fields in a compact binary form.
  • HTTPS is HTTP inside TLS. TLS checks the server's certificate, so you know you are talking to the real example.com, and encrypts everything sent after the handshake: the path, the headers and the body. That is the padlock in the address bar.

What do people get wrong about how the web works?

Mini example

Type http://example.com and the server often answers with a redirect to the secure address, so the browser makes a second request, this time over HTTPS:

GET / HTTP/1.1Host: example.com HTTP/1.1 301 Moved PermanentlyLocation: https://example.com/

Browsers now try HTTPS first by default, and sites can ask to always be visited over HTTPS with the Strict-Transport-Security header, which skips this extra round trip.

Quick check

What does DNS do when you type example.com?

Further reading

All steps as text
  1. Step 1:

    You type example.com and press Enter. The browser turns it into a full URL: https://example.com/.

  2. Step 2:

    First the browser looks in its own cache. A fresh saved copy would be shown at once, with no request; this time there is none.

  3. Step 3:

    To connect, the browser needs the server’s IP address. It asks a DNS resolver: what is the address of example.com?

  4. Step 4:

    The resolver answers with the address, asking other DNS servers first if it doesn’t know it yet. The browser keeps it for next time.

  5. Step 5:

    The browser opens a TCP connection to port 443 at that address: SYN, SYN-ACK, ACK. Now both sides can send data reliably.

  6. Step 6:

    Then TLS: the server proves it is example.com with its certificate, and both sides agree on keys. Everything after this is encrypted.

  7. Step 7:

    Now the HTTP request. GET / asks for the page at the path /, and the headers say which site and what kind of content the browser wants.

    Lines 1–4

  8. Step 8:

    The server works out what to send back. Here it is a ready HTML file; it could also run code to build the page.

  9. Step 9:

    The response starts with a status line: 200 OK means it worked. The headers describe the body: its type, its size, how long to keep it.

    Lines 6–9

  10. Step 10:

    max-age=3600 lets the browser reuse this copy for an hour. A visit within that hour can stop at the cache step.

    Line 9

  11. Step 11:

    After a blank line comes the body: the HTML itself, arriving in pieces over the connection.

    Lines 11–19

  12. Step 12:

    The browser doesn’t wait for the whole file. It starts parsing the HTML as soon as the first bytes arrive, building the DOM.

    Line 11

  13. Step 13:

    One URL, four stops: the cache, DNS, a secure connection, then HTTP. Each image, style and script on the page asks again, usually over the same connection.