Is there a real server push over http?

前端 未结 7 858
走了就别回头了
走了就别回头了 2020-12-05 08:06

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 optio

7条回答
  •  眼角桃花
    2020-12-05 08:37

    As others stated it is impossible for server to contact client without client request (on regular HTTP).

    But if you looking for clean solution for push notificatinons, then look at Server-Sent Events. It is regular HTTP and works seamless with most of the browsers which support HTTP 1.1.

    SSE works only in a single direction (server -> client), which is the main mechanic for push notifications. For client-> server communication you can always use Ajax. I made a summarize of this in Which technology for realtime communication for a web app?

提交回复
热议问题