Search code examples
ajaxwebsocketcometpooling

Polling vs long-polling


What are the differences between polling and long polling? What are the advantages and disadvantages? Is Ajax considered as long-polling?


Solution

  • polling: hitting a url from a client at some interval

    long polling: hitting the url from a client and having the server hold the connection for a period of time, in this way the server can return the connection at the moment when it has information for the client

    Not all ajax is long polling. Long polling is best achieved using a framework like cometd. (http://www.cometd.org)