Polling is a method where the client (browser) continuously checks the server for updates, like chats and dashboards.
🔁 Polling Techniques
| Type | Description | Pros | Cons |
|---|---|---|---|
| Short Polling | Client sends requests at fixed intervals (e.g., every few seconds). Server responds immediately—even with no new data. | Simple to implement | High network/server load / battery drain |
| Long Polling | Client sends a request and waits until the server responds with data. Then sends another request immediately after. | lower latency [fresher data] | More complex to set up |
🧠 Best Practices
🌐 Alternatives to Polling
SSE is a browser-native technology [EventSource API]
wss://EventSource object. Server sends updates using text/event-stream format.