Home

longpolling

Long polling is a web communication technique in which a client requests data from a server and the server holds the request open until new data becomes available or a timeout occurs. When data is available, the server responds with the update. The client then immediately issues a new request, creating a near-continuous stream of updates without maintaining a persistent, full-duplex connection.

How long polling works: The client sends an HTTP request to a server endpoint. If there is

Compared to simple polling, long polling reduces latency by delivering data as soon as it is available

Typical use cases include chat, live notifications, and real-time feeds. Security considerations include using HTTPS, authenticating

no
new
data,
the
server
waits
for
a
specified
period.
If
new
data
arrives
before
the
timeout,
the
server
responds
with
the
data.
If
the
timeout
expires
first,
the
server
responds
with
an
empty
result,
and
the
client
issues
a
new
request.
Upon
receiving
data,
the
client
processes
it
and
repeats
the
cycle.
This
pattern
can
be
implemented
with
standard
HTTP/HTTPS
and
works
with
common
server
environments
and
reverse
proxies.
rather
than
at
fixed
intervals.
Compared
to
WebSockets
or
server-sent
events,
long
polling
can
be
easier
to
deploy
in
environments
with
strict
proxy
or
load-balancer
configurations,
since
it
uses
standard
HTTP
requests.
However,
long
polling
can
be
more
resource-intensive
for
servers,
as
each
connected
client
holds
a
request
open
for
some
time,
and
it
may
require
careful
scaling
with
event-driven
servers,
connection
pooling,
and,
in
some
cases,
sticky
sessions.
clients,
and
validating
data.
Limitations
include
potential
latency
spikes
and
higher
resource
usage
under
large
numbers
of
concurrent
connections.