Skip to content

Web networking

What happens on the wire: HTTP semantics, connections and HTTP/2 and 3, caching headers, CORS, cookies and service workers.

6 lessons

Connection path

  1. 1HTTP semantics: status codes, negotiation and redirectsA status code is data that fetch() hands back, not a verdict; and a redirect repeats the request unchanged only when its code promises to.
  2. 2Connection setup and HTTP/1.1 vs 2 vs 3Setup is paid in round trips, once per connection; HTTP/2 stops requests waiting for each other, but not bytes waiting behind a lost packet.

Caching

  1. 3HTTP caching headersno-cache still stores; no-store never stores. Freshness decides whether the browser asks at all; validation decides whether it downloads again.

Browser security boundaries

  1. 4Same-origin policy and CORSThe browser enforces CORS, not the server: it decides whether a page may read a response and, for non-simple requests, whether to send it.
  2. 5Cookies: attributes, SameSite and partitioningSameSite asks which site started the request, and a site is a registrable domain, not an origin.

Workers and offline

  1. 6Service workers and the offline cacheA service worker is code in front of the network, not another HTTP cache: you write its answers, and updates wait for old tabs.