HTTP, HTTPS and Loading a Web Page
Put everything together by following a web page load step by step, and learn HTTP methods, status codes, TLS certificates and the padlock.
Welcome back!
Step 1 of 13Learn
What happens when you press Enter
Typing https://shop.example.com/cart and pressing Enter sets off a chain of everything in this course so far:
- DNS. The browser needs an IP address for
shop.example.com. It checks its caches and, if needed, asks the resolver, which may walk the DNS hierarchy. - Routing. The destination is not on your subnet, so packets go to your default gateway and then hop by hop across the internet.
- TCP handshake. The browser opens a connection to port 443 with SYN, SYN-ACK, ACK. (With HTTP/3, QUIC over UDP replaces this step.)
- TLS handshake. Client and server agree on encryption keys, and the server proves its identity with a certificate.
- HTTP request. The browser sends
GET /cartwith headers such as the browser type and cookies. - HTTP response. The server returns a status code, headers and the HTML.
- More requests. The page references images, stylesheets and scripts, often dozens or hundreds, many from other domains, each needing DNS and connections of their own.
- Rendering. The browser builds and displays the page.
All this usually takes well under two seconds. Notice how many round trips are involved before the first byte of the page arrives. That's why latency, connection reuse and caching matter so much for web performance, and why content delivery networks (CDNs) place copies of sites in data centers close to users.
Step 2 of 13Practice · Put in order
Put these events in the order they happen when you open an HTTPS website for the first time.
Drag the items, or use the arrow buttons, to put them in order.
- DNS lookup of the site's name
- TCP three-way handshake with port 443
- Browser sends the HTTP GET request
- TLS handshake and certificate check
- Server returns a status code and the HTML
Step 3 of 13Practice · Chart
Where the time goes on a first visit to a site
Which stage takes longest here?
Tap the bar that answers the question, then press Check.
Step 4 of 13Learn
HTTP requests and responses
HTTP (Hypertext Transfer Protocol) is a request-response protocol. The client sends a request with a method, a path and headers; the server answers with a status code, headers and usually a body.
Common methods:
- GET retrieves something: a page, an image, data. It shouldn't change anything on the server.
- POST sends data to create or process something: submitting a form, placing an order.
- PUT and PATCH update existing resources; DELETE removes one. These are common in web APIs.
Status codes are grouped by their first digit:
| Range | Meaning | Examples |
|---|---|---|
| 1xx | informational | 101 Switching Protocols |
| 2xx | success | 200 OK, 201 Created, 204 No Content |
| 3xx | redirection | 301 Moved Permanently, 302 Found, 304 Not Modified |
| 4xx | client error | 400 Bad Request, 401 Unauthorized, 403 Forbidden, 404 Not Found, 429 Too Many Requests |
| 5xx | server error | 500 Internal Server Error, 502 Bad Gateway, 503 Service Unavailable, 504 Gateway Timeout |
The first digit tells you who to look at. A 4xx means the request was the problem: wrong URL, missing login, not allowed. A 5xx means the server failed while handling a valid request. A 502 or 504 often means a proxy or load balancer in front of the site couldn't get a good answer from the application server behind it.
HTTP is stateless: each request stands alone. Logins and shopping carts work by having the browser send a cookie or token with every request.
Step 5 of 13Practice · Sort into groups
Sort each status code by what it tells you.
Tap an item, then tap its group (or drag it there).
Step 6 of 13Learn
HTTPS, TLS and certificates
Plain HTTP sends everything as readable text. Anyone on the path, on public Wi-Fi, at a provider or on a compromised router, could read passwords or change the page. HTTPS is HTTP inside TLS (Transport Layer Security), which provides three guarantees:
- Confidentiality. Traffic is encrypted, so eavesdroppers see only scrambled data. They can still see which server you connect to, but not the pages or form contents.
- Integrity. Any tampering with the data in transit is detected.
- Authentication. The server proves it really is
shop.example.comwith a certificate.
A certificate binds a domain name to a public key and is signed by a certificate authority (CA) that browsers trust. During the TLS handshake the browser checks that the certificate is for the exact name in the address bar, hasn't expired and chains back to a trusted CA. If any check fails, you see a full-page warning. Free automated CAs made certificates available to every site, and today the large majority of web traffic is encrypted.
What the padlock does not mean: that the site is honest. A phishing site at examp1e-login.com can get a valid certificate for its own name. The padlock tells you the connection is private and that you're talking to the domain shown, so always read the domain itself.
Step 7 of 13Practice · Select all that apply
What does HTTPS protect against? Select all that apply.
Select all that apply.
Step 8 of 13Practice · Diagram
A TLS handshake, simplified
At which step would a fake site impersonating your bank usually be caught?
Tap the shape that answers the question, then press Check.
- Client hello
Browser lists the TLS versions and ciphers it supports.
- Server hello + certificate
Server picks settings and sends its certificate.
- Browser checks the certificate
Right name, not expired, signed by a trusted authority.
- Key exchange
Both sides derive the same session keys without sending them.
- Encrypted HTTP
Requests and responses now travel encrypted.
Step 9 of 13Note
Step 10 of 13Practice · Fill in the blanks
Fill in the blanks
A browser shows "404" when the server could not find the requested page; this is a error. A "503" means the is temporarily unable to handle the request.
Step 11 of 13Diagram
HTTP status code families
- Status codes
- 2xx Success
- 200 OK
- 3xx Redirect
- 301 Moved Permanently
- 4xx Client error
- 403 Forbidden
- 404 Not Found
- 5xx Server error
- 500 Internal Server Error
- 503 Service Unavailable
Step 12 of 13Practice · Choose one
Which HTTP method is normally used to submit a sign-up form that creates a new account?
Step 13 of 13Practice · What would you do?
What would you do?
Your company's website suddenly shows "502 Bad Gateway". The site runs behind a load balancer that forwards requests to two application servers. What is the most useful first check?
Lesson complete!