
Node.js can HTTP Push - EGreg
https://medium.com/the-node-js-collection/node-js-can-http-2-push-b491894e1bb1?source=safariShare-a7703696fe94-1523547151
======
EGreg
What are the pros and cons vs Websockets with socket.io, and do all modern
browsers support it?

~~~
jkarneges
All modern browsers support HTTP/2:
[https://caniuse.com/#feat=http2](https://caniuse.com/#feat=http2)

HTTP/2 server push was originally intended as a pre-caching mechanism (send
resources in advance to the client, in case they might get asked for), rather
than for pushing data spontaneously (aka in realtime). As far as I know,
browsers don't yet have a way to notify the application if a resource has been
pre-cached, or offer a way for applications to hijack the push handler to
avoid caching.

So, for now, WebSockets (with or without Socket.io) or HTTP Server-Sent Events
are more appropriate for realtime apps than HTTP/2 server push. Note that you
can send an SSE stream within HTTP/2.

That said, the Web Push protocol
([https://tools.ietf.org/html/rfc8030](https://tools.ietf.org/html/rfc8030))
specifies the use of HTTP/2 server push for delivering data in realtime. So
this could become a more common thing in the future.

