HTTP and REST APIs

Lesson 09 · 11 min

Real time: polling, SSE, WebSocket

HTTP is a question and an answer. What if the server wants to speak first?

11 minLesson 9 of 9Practice includedAsk AI on any point

Plain HTTP doesn't let the server write to the client without a request. There are three approaches. Polling — the client asks every five seconds "anything new?": simple, but wastes requests. SSE (Server-Sent Events) — one long HTTP response of type text/event-stream that the server keeps appending events to; server to client only. WebSocket — a persistent two-way connection for chats, games, and collaborative editing.

Sign in to continue

The rest of this lesson opens after sign up

The first lesson of every course is open without an account. To read on, solve the practice and use Ask, create a free account or log in.