What is long polling?
Answer
Long polling is a technique that simulates real-time server-to-client push using standard HTTP. Instead of the server responding immediately, it holds the request open until new data is available (or a timeout occurs). When the server has data, it responds, the client processes the response, and immediately sends a new request to wait for the next piece of data. This creates a continuous cycle that mimics push behavior. Long polling works everywhere HTTP works (no special protocol support needed) but is less efficient than WebSockets — each "push" requires a new HTTP handshake, headers overhead, and server resources for each held connection. It was the primary real-time technique before WebSockets were widely supported. Socket.IO uses long polling as a fallback transport.
Previous
What is the difference between WebSockets and Server-Sent Events (SSE)?
Next
What is the WebSocket protocol (ws:// and wss://)?