Skip to content
BENIBIX Learn

Polling

Development🌐 Web DevelopmentReal-Time

Also known as Long Polling, Short Polling, HTTP Polling

The browser asks the server, is there news? It asks again and again.

Think of it like

Think of it like a child in a car asking, are we there yet? every few minutes.

Example

Jack's first version checked for new orders every 10 seconds. With 1,000 shop owners online, that was 100 requests a second, mostly empty.

Why it matters

Polling is the easiest way to get updates. Sometimes it is all you need.

Definition

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.

Common mistake

Asking each second for data that changes once an hour. It wastes battery, data and server power.

Key takeaways

  1. 1
    Ask on a timer. Again and again.
  2. 2
    Mostly empty. Many requests bring nothing.
  3. 3
    Long polling waits. The server holds the request.

Compare