Webhook vs Polling
With a webhook, the other service calls you as soon as something happens. With polling, you keep asking it if anything has changed. Webhooks are faster and use less, but your server must be open to the web.
Webhook
A web address for news. Another app calls it when an event takes place.
A webhook is a web address another service calls when something happens. That service sends a POST request to your address with the details. A payment service can tell your shop the moment a payment goes through. You no longer have to keep asking if anything has changed. Your server must answer fast and check that the message is real.
Polling
The browser asks the server, is there news? It asks again and again.
Polling means the browser asks the server for news on a timer. Every few seconds it sends a request. The server answers with new data, or with nothing. It is simple and works in all browsers, but most requests come back empty. Long polling is a smarter version: the server holds each request open until it has news. Both are older ways to get live updates.
In one line
- Webhook
- A web address for news. Another app calls it when an event takes place.
- Polling
- The browser asks the server, is there news? It asks again and again.