Push system without node.JS

I want to create a facebook-like notification system (the one that appears on the bottom left of the screen when someone comments on your post, for example).

The point is that the server should send you a notification when someone comments on the site at that moment. I think it is called PUSH-System (sorry for my bad english).

I tried with node.JS but my dedicated server couldn't install it. Only if I buy a very expensive VPS plan.

So, is there a way to use jQuery or something similar to create this Push notification system?




source to share

2 answers

If you want a low latency, efficient solution, you should use WebSockets. However, you need to have backups such as long polling / short polling if the browser doesn't support WebSockets.

The WebSocket protocol provides full duplex (two-way) communication between the server and client. Traditional HTTP is half duplex (one way). This link will give you an overview of the benefits of using WebSockets vs HTTP: http://www.websocket.org/quantum.html .

You need to know that most modern browsers support WebSockets, but use different protocols. See here: Which browsers support the HTML5 WebSocket API? ...



In addition to the links I posted in the comments above, implementing the Long Polling method is a general solution to eliminate a lot of common polls. Here's what Wikipedia has to say about it:

Long polling is a variation of the traditional polling method and allows the emulation of information flow from server to client. With a long poll, the client requests information from the server in the same way as for regular polls. However, if the server does not have any information available to the client, instead of sending an empty response, the server holds the request and expects some information to be available. As soon as the information becomes available (or after a suitable timeout), the full client is sent. Typically, the client will immediately request information from the server so that the server will almost always have a wait request available that it can use to deliver data in response to an event. In the context of web / AJAX, long polling is also known as comet programming.



All Articles