Long polling is a technique where the client makes a request to the server and the server holds the request open until it has data to send back, allowing for near real-time updates. It's like when you order food delivery and keep refreshing the app every 30 seconds to see if your burrito is on the way yet, except the app would just stay open until the delivery driver actually leaves the restaurant.
I was trying to implement real-time updates in my chat app, but my PM kept bugging me about why I wasn't just using long polling like it's 2005 or something.
"We can't use WebSockets because our ancient corporate proxy blocks them, so I guess we're stuck with long polling and praying to the network latency gods," grumbled the senior engineer.
Long Polling - Concepts and Considerations: A decent overview of long polling, including some code samples, if you really want to implement this blast from the past.
Polling vs SSE vs WebSocket— How to choose the right one: Compares long polling to some more modern alternatives like Server-Sent Events and WebSockets, in case you want to join us in the 21st century.
Asynchronous Polling using the Fetch API: If you're a glutton for punishment, here's a tutorial on implementing long polling using the Fetch API in JavaScript. Don't say I didn't warn you.
Note: the Developer Dictionary is in Beta. Please direct feedback to skye@statsig.com.