Some applications need live data updates.
Polling: Request every N seconds. Simple but inefficient.
Long polling: Server holds request until data changes. More efficient than polling.
WebSockets: Persistent bidirectional connection. Best for chat, live feeds.
Server-Sent Events (SSE): Server pushes updates. Simpler than WebSockets, unidirectional.
When to use what:
- Infrequent updates: Polling
- Chat, gaming: WebSockets
- Notifications, feeds: SSE
Interview tip: WebSockets add complexity. Only use when necessary.