Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a real server push over http?

I know there are ways to fake it, polling (or long polling) but is there any way to have the server contact the browser to push out information?

Either polling option wastes resources on the server and depending on the server can lock it up (apache and iis for example).

Seems like a lot of sites are using long polling to fake a server-side push mechanism over http. Wouldn't it just be better to have a true push protocol built into a browser?

What options are there that are server friendly to push (fake or otherwise) information to web browsers?

like image 672
Justin808 Avatar asked Nov 13 '11 08:11

Justin808


People also ask

How can HTTP be used for server push based application?

HTTP/2 Server Push allows an HTTP/2-compliant server to send resources to an HTTP/2-compliant client before the client requests them. Server Push is a performance technique aimed at reducing latency by loading resources preemptively, even before the client knows they will be needed.

Is HTTP a push protocol?

HTTP server push (also known as HTTP streaming) is a mechanism for sending unsolicited (asynchronous) data from a web server to a web browser. HTTP server push can be achieved through any of several mechanisms.

What is a HTTP push request?

HTTP/2 PUSH allows a web server to send resources to a web browser before the browser gets to request them. It is, for the most part, a performance technique that can help some websites load twice or thrice as fast.

Can a server send request to client?

HTTP Basics As a quick summary, the HTTP/1.1 protocol works as follows: The client (usually a browser) opens a connection to the server and sends a request. The server processes the request, generates a response, and closes the connection if it finds a Connection: Close header.


1 Answers

I know there are ways to fake it, polling (or long polling) but is there any way to have the server contact the browser to push out information?

The connection must be first established by the client to the server. There's no way of a server contacting a web client.

Either polling option wastes resources on the server and depending on the server can lock it up (apache and iis for example).

That's correct. Frequent polling is inefficient which is one of the reasons we are moving to a push world with persistent connections. WebSockets will be the best solution for this. I work for Pusher, a hosted realtime WebSocket solution, and we've seen a massive uptake in this technology driven by a community that believe it's the best solution to the resource and realtime communication problem.

Seems like a lot of sites are using long polling to fake a server-side push mechanism over http. Wouldn't it just be better to have a true push protocol built into a browser?

Yes, that's why we now have WebSockets. HTTP solutions to web browsers are ultimately a hack and don't work consistently (in the same way) between browsers.

What options are there that are server friendly to push (fake or otherwise) information to web browsers?

  • HTTP Long-Polling: The connection is held open until the server has new information. Note: this is different to standard polling where requests for new information can be a complete wast of time.
  • HTTP Streaming: This is probably the solution you are looking for (answering the HTTP question). Using this technique the connection is held open and new pieces of information can be pushed over that existing connection, from server to client, without the connection being closed and re-opened as it is with HTTP Long-Polling.
  • HTTP/2 Server Push: Another standardised mechanism for pushing from server to client. These are known as "pushed responses" and the browser may cache these.
  • WebSockets: Full bi-directional and full duplex communication over a single TCP connection within a web browser (or any web client).

Related information and resources:

  1. You can think Server-Sent Events (the EventSource API) as a standardisation of of HTTP Long-Polling and HTTP-Streaming.
  2. HTTP/2 Server Push
like image 61
leggetter Avatar answered Sep 28 '22 00:09

leggetter