Every request in this book so far started with you. This chapter is about the questions that have no answer yet — has the ride ended? — and the two ways to find out: ask over and over until something changes, or hand the provider an address and let it tell you. The second way swaps the roles Chapter 1 fixed in place, for exactly one message, and then hands you three new responsibilities: proving the message really came from who it claims, surviving the ones that arrive twice, and noticing the ones that never arrive at all.
Eight chapters have run in one direction. You send a request, the server answers, and nothing happens in between that you did not start. That model handled everything up to here because every question had an answer waiting: how many bikes at Old Market, which stations are active, what does page three contain.
Now the office needs to know something that has not happened yet. There are exactly two arrangements for that, and this chapter is both of them: keep asking until the answer changes, or arrange to be told. The first needs nothing new at all. The second needs one new idea, three pages of care, and no new HTTP whatsoever.
Two ways to learn the same thing
Polling · you ask
The request goes out on a timer and mostly comes back saying nothing has changed. Simple, entirely under your control, and priced in requests.
Webhooks · you are told
Nothing travels until the news exists, and then it knocks. Cheap and immediate, at the price of running a door and checking who is at it.