Polling
ELI5 — The Vibe Check
Polling is the 'are we there yet?' of web development. Your client keeps asking the server 'any updates? any updates? any updates?' at regular intervals. Simple but wasteful — most of those requests get 'nope, nothing new.' It works, but there are better ways now.
Real Talk
Polling is a client-side technique where the browser periodically sends HTTP requests to the server to check for new data. Short polling uses fixed intervals (e.g., every 5 seconds). Simple to implement but creates unnecessary network traffic and server load when no updates are available.
Show Me The Code
setInterval(async () => {
const res = await fetch('/api/notifications');
const data = await res.json();
if (data.length > 0) updateUI(data);
}, 5000);
When You'll Hear This
"We started with polling but switched to SSE when the server load got too high." / "Polling every 5 seconds means up to 5 seconds of latency for real-time updates."
Related Terms
Long Polling Pattern
Long Polling is polling's smarter cousin. Instead of asking 'any updates?
Server-Sent Events Pattern
Server-Sent Events (SSE) is a one-way stream from server to browser over plain HTTP. The server pushes updates, the client just listens.
WebSocket
WebSocket is like upgrading a walkie-talkie from push-to-talk to a full phone call.