Chapter 2: The network

The fastest request is the one that never has to make the trip.

Caching in the browser and on the way

Also called HTTP cache, Cache-Control

A saved copy of a response, kept by the browser or by something between you and the server, so the same request needn't travel again. The Cache-Control header sets the rules. It makes sites fast, and it's why people see old versions.

Agents add caching when asked to speed things up, and rarely work out how the new version will reach people, which is the harder half. "I deployed and nothing changed" is often this. So is a private page served to the wrong person.

Say it to your agent

“Serve files in /assets/ with Cache-Control: max-age=31536000, immutable, and only if their names contain a content hash. Serve index.html with no-cache and /api/account with private, no-store. Show me the response headers for all three.”

The workshop

Name a word, or describe what you mean in everyday language.