freecoding.school100% FREE · NO SIGNUP
Endpoint BayISSUE #29 of 45

polling vs long-polling vs push

RestaVSThe 401 Bandit
Resta saysPolling repeatedly asks for updates; long-polling and push reduce its waste.

Short polling hits the server on a timer ("anything new?") — simple but wasteful and laggy. Long polling holds the request open until there's data, cutting empty responses. Push (SSE/WebSockets) eliminates polling entirely. Reach for push when updates are frequent or latency matters; polling is fine for slow-changing data.

Power-ups you unlock

The 401 Bandit attacks — common mistakes

Boss battleRank short-poll, long-poll, and push by latency and server cost.

Example code

<!doctype html><html><head><meta charset="utf-8"></head>
<body style="background:#06040d;color:#e6e0ff;font-family:monospace;padding:20px"><pre>short poll → many empty requests, laggy
long poll  → hold until data, fewer requests
push (SSE/WS) → instant, no polling</pre></body></html>
▶ Open the interactive comic issue
‹ Server-Sent Events · One-Way RealtimeAuthentication · Who Are You ›