It seems in both cases client sends a request to server and server answers, unless in server sent event you can set retry time in your server side code. So is there any benefit in using SSE rather than jQuery post or g开发者_运维知识库et method?
SSE is not supported by IE but you can make it work with IE 8+ if you use a library.
Server sent events create less traffic on the server. The client does not need to ask for news every minute. Data is only delivered when it is available. Also the data arrives instantly at the client not only when the client ask for it.
If you like to use SSE you should use a library like Yaffle's EventSource.
Using SSE is better because the request weight is far less than long polling. In long polling you need to issue a HTTP request each time but in SSE, you just need to use one HTTP connection for sending data from the server to the client.
Implanting SSE in server is easy to do (especially in node.js).
Here is a PHP library for handling SSE and it's created by me.
Hope these things can help you.
精彩评论