edubun
English
1 / 19

6 / 6 · Basic

What happens when you open a web page

With a 50 ms round trip, an HTTPS page needs at least 4 round trips, 200 ms, before the first byte of HTML arrives. HTTP/3 cuts one.

Jump to the 10 practice questions

You will learn

  • Split a URL into scheme, host, path, query and fragment
  • Read HTTP status codes

Before this: DNS: turning names into addresses

1Explain

The lunch menu on a crowded train

Seven forty in the morning. A student on a crowded train taps a link to the school lunch menu on mobile data, and a moment later today's menu appears. (This is a made-up scene.) In that moment the phone did everything from the last five units: a DNS lookup, a TCP connection, an encrypted session, and an HTTP request answered with a status code. Follow the phone through it and count the waits.

2Explore

First the phone reads the link

Say the link is https://www.example.com/index.html. MDN breaks a URL into parts. https is the scheme: use HTTP over an encrypted TLS connection, on port 443 unless another port is written. www.example.com is the host, the name DNS will turn into an address. /index.html is the path, the resource asked for on that server. A URL can also carry a query after a question mark and a fragment after a hash sign. The fragment points to a spot inside the page and is never sent to the server.

The URL object splits a link into its parts: scheme, host (with a port if one is written), path, query and fragment.

URL
const u = new URL("https://www.example.com/menu?day=mon#lunch");
console.log(u.protocol);
console.log(u.host);
console.log(u.pathname);
console.log(u.search);
console.log(u.hash);
Output
https:
www.example.com
/menu
?day=mon
#lunch

3Problem

/index.html

In https://www.example.com/index.html, what is /index.html?

Hint

What comes after the host.

Solution

Answer: The path

Scheme https, host www.example.com, path /index.html.

4Problem

The default HTTPS port

Which port does https:// use when no port is written?

Hint

The same as in the TCP unit.

Solution

Answer: 443

The default port for HTTPS is 443.

5Explore

Four round trips before the first byte

The time for a message to reach the server and for the reply to come back is the round-trip time (RTT). Count the round trips and you can see where the wait comes from. One: in this simplified model, count DNS as one round trip if the name is not cached. A real uncached lookup can take longer because the resolver may need to contact other servers. Two: the TCP handshake, SYN out and SYN-ACK back. Three: TLS 1.3 (RFC 8446) agrees on keys in one round trip, and the client's last handshake message can travel with the HTTP request.

Loading

Drag to turn. Scroll or pinch to zoom.

Press Next step to add each message, or Show all. Switch between HTTPS, plain HTTP and HTTP/3 and move the round-trip slider. The count at the left edge shows how many round trips have passed. Server thinking time and page size are left out.

6Problem

The order of the steps

Put these in order for loading an HTTPS page.

  1. TCP handshake
  2. TLS handshake
  3. HTTP request and response
  4. DNS lookup
Hint

Name, then connection, then encryption, then the request.

Solution

Answer:

  1. DNS lookup
  2. TCP handshake
  3. TLS handshake
  4. HTTP request and response

The address comes first, then the connection, then encryption, then the request.

7Problem

HTTPS at 50 ms

RTT is 50 ms. How long before the first byte of an HTTPS page (TCP + TLS 1.3), counting the DNS lookup?

ms

Hint

Four round trips × 50 ms.

Solution

Answer: 200 ms

4 round trips × 50 ms = 200 ms.

8Problem

Cached name, 80 ms

RTT is 80 ms and the name is already cached. How long does an HTTPS page over TCP take?

ms

Hint

No DNS round trip: three left.

Solution

Answer: 240 ms

No DNS round trip: TCP + TLS + request = 3 × 80 = 240 ms.

9Explain

HTTP/3 and plain HTTP

HTTP/3 (RFC 9114) runs on QUIC (RFC 9000) instead of TCP. QUIC sits on UDP and sets up the connection and the TLS keys together, so the separate TCP round trip disappears: DNS, one handshake round trip, then the request, three in all. Plain HTTP on port 80 skips TLS and also needs three, but then anyone on the path, such as whoever runs a café's Wi-Fi, can read or change the page. The padlock in the address bar means the connection to that domain is encrypted.

10Problem

HTTP/3 at 50 ms

Same 50 ms RTT, but over HTTP/3. How long?

ms

Hint

Three round trips × 50 ms.

Solution

Answer: 150 ms

QUIC merges the transport and TLS handshakes: 3 × 50 = 150 ms.

11Problem

Under HTTP/3

Which transport does HTTP/3 run on?

Hint

QUIC sits on UDP.

Solution

Answer: QUIC over UDP

RFC 9114 maps HTTP onto QUIC (RFC 9000), which uses UDP.

12Problem

The padlock

What does the padlock in the address bar tell you?

Hint

It is about the connection, not about honesty.

Solution

Answer: The connection to that domain is encrypted

TLS protects the connection. A scam site can have a padlock too.

13Explain

The menu arrives with a number in front

The reply starts with a three-digit status code. RFC 9110 groups codes by their first digit: 1xx informational, 2xx success, 3xx redirection, 4xx client error and 5xx server error. The ones you will meet most are 200 OK, 301 Moved Permanently (the page has a new address), 404 Not Found and 500 Internal Server Error. If the school had moved the menu page, the phone would first get a 301 and then ask again at the new address. A 404 means the server answered and had nothing at that path, so the network itself was working.

14Problem

404

What does 404 mean?

Hint

4xx is a client error.

Solution

Answer: Not Found

4xx codes are client errors; 404 says the server has nothing at that path.

15Problem

Redirection

Which class of status codes means redirection?

Hint

301 belongs to it.

Solution

Answer: 3xx

RFC 9110: 3xx tells the client to look somewhere else, such as 301.

16Explain

One page, many files

The HTML is rarely the whole page. Say it mentions a style sheet, a script and five images. If the phone opened a new connection for each, every file would pay the TCP and TLS round trips again. Instead the browser keeps the connection open and sends the next requests on it, and with HTTP/2 and HTTP/3 several requests travel on one connection at the same time. Browsers also keep their own cache. When a response says it may be reused for a while, the next visit loads that file from storage without sending any request.

17Practice

Time to the first byte

Finish firstByte(rtt, kind, cached): count the round trips (DNS 1 unless cached, TCP 1 for "https" and "http", TLS 1 for "https", the QUIC handshake 1 for "http3", the request 1) and return them times rtt.

Expected output
200
150
240
60
Your code
function firstByte(rtt, kind, cached) {
  let trips = 1;
  return trips * rtt;
}
console.log(firstByte(50, "https", false));
console.log(firstByte(50, "http3", false));
console.log(firstByte(80, "https", true));
console.log(firstByte(30, "http", true));
Hint

HTTP/3 sets up the connection and the keys together, in one round trip.

A solution
function firstByte(rtt, kind, cached) {
  let trips = 1;
  if (!cached) trips++;
  if (kind === "https" || kind === "http") trips++;
  if (kind === "https") trips++;
  if (kind === "http3") trips++;
  return trips * rtt;
}
console.log(firstByte(50, "https", false));
console.log(firstByte(50, "http3", false));
console.log(firstByte(80, "https", true));
console.log(firstByte(30, "http", true));

18Explain

Common mistakes

  • "The padlock means the site is safe."

    The padlock only says the connection to that domain is encrypted with TLS. A scam site can have one too, so check that the domain is the one you meant.

  • "Incognito mode hides what I visit from my ISP and my school."

    Incognito mode stops the browser keeping history and site data on your device after the session ends. Google's Chrome Help says the sites you visit, and organisations that manage your network such as a school, an employer or an internet service provider, may still be able to observe your activity. Your packets cross the same routers either way.

  • "A 404 means the internet is down."

    A 404 is an answer from the server: it was reached and has nothing at that path. When the network really is down, no status code arrives at all.

  • "The part after # in a link is sent to the server."

    The fragment stays in the browser and only picks a spot inside the page. It is never sent to the server.

19

Summary

  • A URL has a scheme (https), a host (DNS name) and a path.
  • HTTPS over TCP: DNS + TCP + TLS 1.3 + request = 4 round trips before the first byte.
  • HTTP/3 over QUIC merges the handshakes: 3 round trips.
  • Status codes: 2xx success, 3xx redirection, 4xx client error, 5xx server error.

Back to the courseHow the internet works
Full text · The whole lesson as one text

Seven forty in the morning. A student on a crowded train taps a link to the school lunch menu on mobile data, and a moment later today's menu appears. (This is a made-up scene.) In that moment the phone did everything from the last five units: a DNS lookup, a TCP connection, an encrypted session, and an HTTP request answered with a status code. Follow the phone through it and count the waits.

First the phone reads the link

Say the link is https://www.example.com/index.html. MDN breaks a URL into parts. https is the scheme: use HTTP over an encrypted TLS connection, on port 443 unless another port is written. www.example.com is the host, the name DNS will turn into an address. /index.html is the path, the resource asked for on that server. A URL can also carry a query after a question mark and a fragment after a hash sign. The fragment points to a spot inside the page and is never sent to the server.

Four round trips before the first byte

The time for a message to reach the server and for the reply to come back is the round-trip time (RTT). Count the round trips and you can see where the wait comes from. One: in this simplified model, count DNS as one round trip if the name is not cached. A real uncached lookup can take longer because the resolver may need to contact other servers. Two: the TCP handshake, SYN out and SYN-ACK back. Three: TLS 1.3 (RFC 8446) agrees on keys in one round trip, and the client's last handshake message can travel with the HTTP request. Four: the request goes out and the response comes back. With a 50 ms RTT, that is 200 ms before the first byte of the menu, even if the server answers instantly.

Press Next step to add each message, or Show all. Switch between HTTPS, plain HTTP and HTTP/3 and move the round-trip slider. The count at the left edge shows how many round trips have passed. Server thinking time and page size are left out.

HTTP/3 (RFC 9114) runs on QUIC (RFC 9000) instead of TCP. QUIC sits on UDP and sets up the connection and the TLS keys together, so the separate TCP round trip disappears: DNS, one handshake round trip, then the request, three in all. Plain HTTP on port 80 skips TLS and also needs three, but then anyone on the path, such as whoever runs a café's Wi-Fi, can read or change the page. The padlock in the address bar means the connection to that domain is encrypted. It does not mean the site itself is honest.

The menu arrives with a number in front

The reply starts with a three-digit status code. RFC 9110 groups codes by their first digit: 1xx informational, 2xx success, 3xx redirection, 4xx client error and 5xx server error. The ones you will meet most are 200 OK, 301 Moved Permanently (the page has a new address), 404 Not Found and 500 Internal Server Error. If the school had moved the menu page, the phone would first get a 301 and then ask again at the new address. A 404 means the server answered and had nothing at that path, so the network itself was working.

One page, many files

The HTML is rarely the whole page. Say it mentions a style sheet, a script and five images. If the phone opened a new connection for each, every file would pay the TCP and TLS round trips again. Instead the browser keeps the connection open and sends the next requests on it, and with HTTP/2 and HTTP/3 several requests travel on one connection at the same time. Browsers also keep their own cache. When a response says it may be reused for a while, the next visit loads that file from storage without sending any request. The browser can display some content while other files are still loading. Images and other resources may appear later. That is why the menu page the student opens every morning appears faster than a site opened for the first time, even on the same network.

Common mistakes
  • "The padlock means the site is safe." The padlock only says the connection to that domain is encrypted with TLS. A scam site can have one too, so check that the domain is the one you meant.
  • "Incognito mode hides what I visit from my ISP and my school." Incognito mode stops the browser keeping history and site data on your device after the session ends. Google's Chrome Help says the sites you visit, and organisations that manage your network such as a school, an employer or an internet service provider, may still be able to observe your activity. Your packets cross the same routers either way.
  • "A 404 means the internet is down." A 404 is an answer from the server: it was reached and has nothing at that path. When the network really is down, no status code arrives at all.
  • "The part after # in a link is sent to the server." The fragment stays in the browser and only picks a spot inside the page. It is never sent to the server.
Teacher's noteThis unit pulls the whole course together, so before showing the diagram, ask learners to explain the order in their own words: why the name must become an address before any connection, and why encryption has to be set up before the request goes. Counting round trips is the part that stays with them. Work 50 ms by hand, then have them predict the total before they move the slider. The padlock and incognito mistakes are not about speed, but give them a few minutes anyway, because learners act on both beliefs.
Key points
  • A URL has a scheme (https), a host (DNS name) and a path.
  • HTTPS over TCP: DNS + TCP + TLS 1.3 + request = 4 round trips before the first byte.
  • HTTP/3 over QUIC merges the handshakes: 3 round trips.
  • Status codes: 2xx success, 3xx redirection, 4xx client error, 5xx server error.

Practice questions from What happens when you open a web page on edubun

Embed this quiz

Free to embed. Please keep the credit line.

Sources for this course (27)
  • (checked 2026-10-17)
  • IETF RFCs (rfc-editor.org): RFC 768 UDP (1980, 8-byte header)
  • RFC 791 IPv4 (1981, 32-bit addresses, "does not provide a reliable communication facility", TTL field "measured in units of seconds" but every module must decrease it by at least one, so it is only an upper bound)
  • RFC 792 ICMP (Time Exceeded)
  • RFC 801 NCP/TCP transition plan (1 January 1983)
  • RFC 894 Ethernet (1500-byte payload)
  • RFC 1034 and RFC 1035 DNS (1987, HOSTS.TXT kept by SRI-NIC, labels up to 63 octets and names up to 255, TTL in seconds)
  • RFC 1122 (127.0.0.0/8 loopback)
  • RFC 1918 private addresses (10/8, 172.16/12, 192.168/16)
  • RFC 2131 DHCP, RFC 3022 NAT, RFC 3596 AAAA records, RFC 3849 and RFC 5737 documentation addresses, RFC 4271 BGP-4, RFC 4291 IPv6 text form, RFC 6298 TCP retransmission timer (initial RTO 1 second)
  • RFC 6335 port ranges (0-1023, 1024-49151, 49152-65535)
  • RFC 7766 DNS over TCP, RFC 8200 IPv6 (128-bit addresses, Hop Limit)
  • RFC 8446 TLS 1.3 (one round-trip handshake)
  • RFC 9000 QUIC and RFC 9114 HTTP/3, RFC 9110 HTTP semantics (status code classes)
  • RFC 9293 TCP (three-way handshake, sequence numbers)
  • IANA: ip-parameters registry (recommended default TTL 64)
  • IPv4 free pool depleted 3 February 2011 (NRO and ARIN announcements)
  • Official documentation: MDN Web Docs "How does the Internet work?" (45 cables for 10 computers, switches, routers, MAC and IP addresses, internet and web)
  • "What is a URL?", "HTTP response status codes" (developer.mozilla.org)
  • Cloudflare Learning Center: "What is DNS?" (four kinds of DNS server, 8 steps of an uncached lookup, browser and OS caches, TTL)
  • "What is HTTP/3?" (cloudflare.com/learning)
  • Google Chrome Help, "Browse in Incognito mode" (support.google.com/chrome/answer/95464, checked 2026-10-19: Incognito limits what is saved to the device; websites and organisations that manage your network, like your school, employer or internet service provider, may be able to observe your activity)
  • Operators and papers: root-servers.org (13 root name servers run by 12 organisations, 2047 instances on 2026-10-17)
  • Jacobson and Karels 1988, Congestion Avoidance and Control (loss mostly congestion)
  • History blocks only: UCLA Samueli School of Engineering, Internet50 (first ARPANET message "LO", UCLA to SRI, 29 October 1969, 22:30)
  • historyofinformation.com and Wikipedia ARPANET (Kline)
  • Spiceworks/SRI history (HOSTS.TXT kept by SRI-NIC).

Checked: 2026-10-17