为什么本机服务器发送事件 (SSE) 比 polyfill 替代方案更有效?
Why are native Server-Sent Events (SSE) more efficient than the polyfill alternative?
谁能解释一下作者的意思,说 "native XHR streaming" 比 "XHR polling." 更有效率
我很想知道是否有更有效的方法将数据从服务器流式传输到客户端(使用 XHR - 这不是关于网络套接字的问题)。据我所知,SSE 基本上只是提供了一个 API 来执行 "chunked" 服务器响应,并添加了一些功能,如连接恢复。 SSE 实施是否真的提高了性能?
While a polyfill will provide a consistent API, be aware that the
underlying XHR transport will not be as efficient:
XHR polling will incur message delays and high request overhead. XHR
long-polling minimizes latency delays but has high request overhead.
XHR streaming support is limited and buffers all the data in memory.
Without native support for efficient XHR streaming of event stream
data, the polyfill library can fallback to polling, long-polling, or
XHR streaming, each of which has its own performance costs.
高性能浏览器网络,作者:Ilya Grigorik
https://hpbn.co/server-sent-events-sse/#emulating-eventsource-with-custom-javascript
XHR 流式传输和 SSE 在性能方面非常相似,只是通常认为 XHR 流式传输 "an unsupported feature in modern browsers" 因为除非重新连接,否则无法清除缓冲区。这个答案解释了所有这些并提出了一个非常麻烦的解决方法:.
SSE 实现只是在收到每个事件后清除缓冲区,请参阅:https://dxr.mozilla.org/mozilla-central/source/dom/base/EventSource.cpp。
谁能解释一下作者的意思,说 "native XHR streaming" 比 "XHR polling." 更有效率
我很想知道是否有更有效的方法将数据从服务器流式传输到客户端(使用 XHR - 这不是关于网络套接字的问题)。据我所知,SSE 基本上只是提供了一个 API 来执行 "chunked" 服务器响应,并添加了一些功能,如连接恢复。 SSE 实施是否真的提高了性能?
While a polyfill will provide a consistent API, be aware that the underlying XHR transport will not be as efficient:
XHR polling will incur message delays and high request overhead. XHR long-polling minimizes latency delays but has high request overhead. XHR streaming support is limited and buffers all the data in memory.
Without native support for efficient XHR streaming of event stream data, the polyfill library can fallback to polling, long-polling, or XHR streaming, each of which has its own performance costs.
高性能浏览器网络,作者:Ilya Grigorik https://hpbn.co/server-sent-events-sse/#emulating-eventsource-with-custom-javascript
XHR 流式传输和 SSE 在性能方面非常相似,只是通常认为 XHR 流式传输 "an unsupported feature in modern browsers" 因为除非重新连接,否则无法清除缓冲区。这个答案解释了所有这些并提出了一个非常麻烦的解决方法:
SSE 实现只是在收到每个事件后清除缓冲区,请参阅:https://dxr.mozilla.org/mozilla-central/source/dom/base/EventSource.cpp。