Chapter 01 · HTTP only answers01 / 19

Alice sends, Bob waits

Alice and Bob are chatting in a web app. Alice types a message and hits send. Her browser does what browsers do: it makes an HTTP request, POST /messages. The server stores the message and answers 201 Created.

Now look at Bob's window. Nothing new. The message is sitting on the server, and the server has no way to hand it over.

That's the deal HTTP makes: the client always speaks first. A browser sends a request, the server sends back exactly one response, and that exchange is over. A server can't start a new one on its own.

chat.js · Alice’s browserin the real world
await fetch('/messages', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ room: 42, text: 'Lunch at noon?' }),
});
// 201 Created. Bob's browser hears nothing.