Summary
- A URL has a scheme, a host, an optional port, a path, an optional query string of name and value pairs, and an optional fragment, which the browser never sends to the server.
- DNS turns a host name into an IP address, working down from the root to the domain's authoritative name server, with answers cached for their time to live. A failed lookup gives a browser error with no status code.
- An HTTP request has a request line (method, path and version), headers and an optional body. A response has a status line, headers and usually a body, separated from the headers by a blank line.
- GET and HEAD are safe and only read. POST sends data to be acted on and is neither safe nor idempotent, so a GET must never change anything.
- Status codes are read by their first digit: 2xx success, 3xx redirect, 4xx a problem with the request, 5xx a failure on the server.
- Headers such as Content-Type, Cache-Control, Location, Set-Cookie and Cookie explain most of what goes wrong with a page that "loads but does not work".
- HTTP is stateless. Sites remember you with cookies, usually a session cookie holding only an identifier, protected with Secure, HttpOnly and SameSite.
- The Network panel shows every request with its status, size, timing and headers, and can disable the cache and simulate a slow connection.
- In the terminal, pwd, ls, cd and mkdir move around and create folders, relative paths start from where you are, and curl sends HTTP requests directly. On Windows PowerShell, type curl.exe.
- Use lower case and no spaces in file names, because web servers usually run Linux, where file names are case-sensitive.