How does a chat server deliver a message to a user who is not making a request?
Sketch your own answer first, then compare it with the one below.
A strong answer
The user keeps a persistent connection open to the server, usually a WebSocket. The server writes the message to that connection when it arrives.
A normal request and response cannot do this, because the client has to ask first. The server therefore needs to track which connection belongs to which user.
Sources
- Ian Fette, Alexey Melnikov (2011). RFC 6455: The WebSocket Protocol.