Long Polling and Short Polling (original) (raw)
Last Updated : 5 May, 2026
Polling is a technique where a client repeatedly sends requests to a server at fixed intervals to check for new data. It is widely used to simulate real-time updates when instant communication is not strictly required. Although it is not truly real-time, polling is simple to implement and works reliably in many applications.
- Easy to implement and widely supported across systems, as it does not require persistent connections like WebSockets.
- However, frequent client requests can increase server load and impact performance.
**Example: A news app refreshing every 10 seconds to fetch the latest headlines from the server.
Short Polling
Short polling is a technique where the client continuously sends requests to the server at fixed intervals. The server immediately responds—either with data if available or an empty response if not. This cycle keeps repeating, allowing the client to check for updates regularly.
- Simple to implement using standard HTTP/AJAX requests without complex setup.
- Can cause unnecessary requests and increase server load due to frequent polling even when no new data is available.
**Example: A chat application that sends a request to the server every 5 seconds to check for new messages, even if no new messages have arrived.

Implementation Example
In this example, we took the server file as _data.json which contains some data.
HTML `
Short Polling using AJAX