HTML and CSS Reference
then reuse the cached version for every other page that uses it. For any users who visit more
than one page on your site, this means fewer network requests and therefore lower latency.
For transferring small and largely independent portions of data, all of these extra headers
are a waste. The data is unique; otherwise, there's no point sending it, which means you've
nothing to gain from caching.
That's not the only problem with using HTTP for data transfer. What if the client only
wants to check to see if there's new data available, a process known as polling ? Each poll
will come with all the baggage of those HTTP headers. Polling can be inefficient to start
with, which makes it a poor choice for real-time applications. The next section will exam-
ine this issue in more detail.
D.4. Polling vs. event-driven
The phrase “real-time web” has become fashionable in recent years. Although it's based on
a number of trends, the real-time web embodies a shift from the traditional client polling
approach in web applications to a more event-driven approach. Instead of clients deciding
when to ask the server if there's new information, the server sends new information to the
client when it's ready.
Event-driven approaches are far more efficient than polling. This section will demonstrate
that point with a series of timeline diagrams. Figure D.3 illustrates an optimum case for