Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between Push API and Server Sent Events?

From the documentation I could figure out that Push API and Server Sent Events both are half duplex but why two different technologies for the same functionality? Is there something more significant in Push API?

like image 513
Rishul Matta Avatar asked Mar 29 '15 09:03

Rishul Matta


People also ask

Is SSE a push notification?

Server sent events(SSE) is a pushing technology that enables pushing notification/message/events from the server to the client(s) via HTTP connection.

What is push API?

The Push API gives web applications the ability to receive messages pushed to them from a server, whether or not the web app is in the foreground, or even currently loaded, on a user agent.

What is meant by server sent events?

A server-sent event is when a web page automatically gets updates from a server. This was also possible before, but the web page would have to ask if any updates were available. With server-sent events, the updates come automatically.

When to use server sent events vs Websockets?

SSE is best used when it's not necessary to send data from client to server. For example, in status updates and push notification applications, the data flow is from the server to the client only. This is what SSE is designed for, so WebSocket would be overkill. It's always wise to use the best tool for the job.


1 Answers

The Push API allows the server to send a notification to a client even when your site is not open, because it relies on service workers.

SSE (or WebSockets) work as long as the user is using your site.

There are some examples (with documentation) in the Web Push section of the ServiceWorker Cookbook that can help you understand this better.

like image 133
Marco Castelluccio Avatar answered Sep 24 '22 04:09

Marco Castelluccio