Parece simples até o entrevistador perguntar "why?". Abaixo, uma estrutura de resposta que dá conta do follow-up.
Short polling: the client requests updates periodically. Detection delay can approach the interval plus request time. Shorter intervals increase request load.
Long polling: the server holds a request until an update or timeout, then the client opens another request. Configure deadlines and reconnect backoff.
SSE: a server-to-client event stream over HTTP. Browser EventSource supports reconnect and event IDs, but replay requires server support. Native EventSource uses GET and has no arbitrary-header option. A POST response can use SSE framing read through fetch, but the application must handle parsing, cancellation, and reconnect itself.
WebSockets: a persistent full-duplex channel for frequent messages in both directions. The application still needs authentication, authorization, flow control, and recovery.
Rule of thumb: SSE can fit server push such as notifications or generated text. WebSockets can fit frequent bidirectional interaction. Ordinary HTTP or polling can be simpler when updates are infrequent.
Ler é o primeiro passo. No app, essa pergunta vira flashcard com repetição espaçada, e o módulo tem quiz e simulado para testar o que ficou.
Treinar essa pergunta no app