AJAX - The Complete Reference

(avery) #1

PART III


Chapter 10: Web Services and Beyond 517


Approach Description Comments
Fast poll Calls the server very rapidly using a
standard XHR call to see if changes
are available.

Uses standard HTTP request to a Web server.

Not really a push but if continuous enough
appears as instantaneous.

Significant burden on server and network with
numerous requests.

No way for server to initiate the data transfer.
Long poll Uses an XHR, but we hold the
connection open for an extended
period of time say 20-30 seconds.
After the time threshold is reached,
the connection is shut down and
re-established by the client. The
server may push data down the
held connection at any time and
thus shut the connection, which the
browser will immediately re-open.

Uses standard Web server with HTTP
connections.
Server can push data to browser assuming there
is a held connection open.

Held connections and some Web server-
application server architectures may not get
along well.

Gap of no connectivity when browser re-establishes
connection after data transfer or timeout.
Slow load Uses an iframe that points to a
never finishing URL. The URL in
question is a program that pushes
data when needed to the iframe,
which then can call upward into the
hosting page to provide the newly
available data.

Does not use an XHR and thus lacks some
networking and script control, though as an
iframe it works in older browsers.

Continuous load can present some disturbing
user interface quirks such as a never finishing
loading bar.

Tends to result in growing browser memory
consumption and even crashes if connection
held open for a very long time.
Binary
bridge

Uses Flash or Java applet to make a
socket connection to the server. As
two-way communication, the socket
provides full push possibilities.
Received data is made available via
JavaScript from the communications
helper binary.

Relies on binary that may not be installed.

Piping between JavaScript and binary may be
problematic.

Very flexible in terms of communication methods
and data formats.
Native
browser
access

In some browsers like Opera 9
you should be able to subscribe
to server events that will wake
the browser when data is made
available.

Uses native browser facilities.
Apparently works similarly to an endless iframe
from a network point of view.

Not widely implemented as of yet.

TABLE 10-2 Summary of Push-style Communications Approaches
Free download pdf