appzasGamesToolsDevLearnCheat sheetsQuick calcsConvertersReferenceNetworkTimeCalculatorsCompareLLM prices

How the web works

Lesson 1 of 48 minBeginner

URLs, clients and servers, and the steps between typing an address and seeing a page.

The web is a conversation between a client (your browser, an app or a command like curl) and a server. They speak HTTP, the HyperText Transfer Protocol: the client sends a request, the server sends back a response.

Anatomy of a URL

https://www.example.com:443/guides/http?lang=en#headers
\___/   \_____________/ \_/ \___________/ \______/ \_____/
scheme       host      port     path        query   fragment
  • scheme: the protocol, http or https.
  • host: the server name, resolved to an IP address by DNS.
  • port: optional, 80 for HTTP and 443 for HTTPS by default.
  • path: which resource on the server.
  • query: extra parameters after ?.
  • fragment: a position inside the page after #. It is handled by the browser and never sent to the server.

What happens when you open a page

  1. The browser asks DNS for the IP address of the host.
  2. It opens a connection to that address on port 443.
  3. For HTTPS, client and server agree on encryption (TLS) and the server proves its identity with a certificate.
  4. The browser sends an HTTP request.
  5. The server sends an HTTP response: a status code, headers and usually a body.
  6. The browser reads the HTML and makes more requests for images, styles and scripts.

HTTP versions

HTTP/1.1 is text-based, one request at a time per connection. HTTP/2 multiplexes many requests over one connection. HTTP/3 runs over QUIC on UDP port 443. The semantics (methods, status codes, headers) are the same in all of them.

See it yourself

curl -v https://example.com    # -v shows the connection, TLS handshake, request and response headers

Test yourself

Answer all the questions, then check them. Finish with every answer right to mark the lesson as done.

1. Which part of a URL is never sent to the server?
2. What is the default port for HTTPS?
3. What happens first when you type a host name in the browser?
Hintcurl has a verbose option.

Key terms