5 ms·
HTTP/2 Push was really useful when we wanted to avoid Websocket , Ajax Polling , Long Polling. The problem with not adopting is due to Websocket getting more p
by v3ss0n 2y ago
HTTP/2 Push was really useful when we wanted to avoid Websocket , Ajax Polling , Long Polling.
The problem with not adopting is due to Websocket getting more popular and Devs stop caring about HTTP2 altogether. But there are many cases Websocket is overkill , even text chat application dosen't need websocket.
Similar functionality can already be achieved by using SSE/Eventsource although HTTP/2 Push was more powerful.
- creesch 2y agoIn what practical sense are websockets overkill? As far as I know, the resource usage isn't really all that different. It also isn't as if websockets are that difficult to use these days. I am also skeptical of the "doesn't need websocket" statement. It is technically true that you can use other technologies. But, WebSockets provide bidirectional communication, while Ajax Polling and Long Polling are used for periodic updates. HTTP/2 Push is more suited for pushing resources or data from the server to the client. As far as my understanding goes the use case there is specifically aimed at pushing resources the server "knows" the client will need as well without the client requesting them. I am sure that with some creative code you can also use this to implement a chat of sorts but that is a bit besides the point.
- plopz 2y agoIs there any reason to use websockets over webtransport now?
- creesch 2y agoAbsolutely: https://developer.mozilla.org/en-US/docs/Web/API/WebTransport#browser_compatibility https://developer.mozilla.org/en-US/docs/Web/API/WebTranspor...
- deleted 2y ago[deleted]
- diggan 2y agoProbably the most major one is if you want cross-browser support, AFAIK, WebTransport still isn't available in Safari.
- nirui 2y agoAre you talking about Server-sent Events (https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events https://developer.mozilla.org/en-US/docs/Web/API/Server-sent...)? Which can be implemented under HTTP/1 too. HTTP/2 Server Push is another thing. It allows server to send additional related resources to a client without the client explicitly requesting.
- klabb3 2y agoNot wrong, but for context: websocket http/1.1 only. It cannot use http/2 at all.
- nirui 2y agoI think it's more of a problem on the implementation side. IETF RFC 8441 (https://www.rfc-editor.org/rfc/rfc8441.html https://www.rfc-editor.org/rfc/rfc8441.html) described a way to bootstrap WebSocket under HTTP/2. That said, I don't know whether or not people are actually doing it in the wild.
- realharo 2y agoAs far as web frameworks go, WebSockets over HTTP/2 are supported in for example ASP.NET by default (https://learn.microsoft.com/en-us/aspnet/core/fundamentals/websockets?view=aspnetcore-8.0#http2-websockets-support https://learn.microsoft.com/en-us/aspnet/core/fundamentals/w...). There is however still a surprising amount of languages/libraries/frameworks/servers where the support is missing (e.g. go https://github.com/golang/go/issues/49918 https://github.com/golang/go/issues/49918). On the client side, both Chrome (https://chromestatus.com/feature/6251293127475200 https://chromestatus.com/feature/6251293127475200) and Firefox will use it when available, but I have encountered some issues with cross-origin support (https://issues.chromium.org/issues/363015174 https://issues.chromium.org/issues/363015174)
- klabb3 2y agoGP here. This was completely new to me despite working with it day to day. Thanks for sharing. This gives me some hope about having websockets be more in line with the rest of the stack.
- bawolff 2y agoPerhaps i misunderstand, but i feel like http2 push was trying to achieve something very different than websicket/ajax poling/long polling/sse. They dont seem comparable to me at all.
- Lio 2y agoThat's an interesting point, would you mind elaborating on how you think the goals of HTTP2 Push differed? Even is if is a misunderstanding it would still be useful to consider.
- creesch 2y agoI don't know how to ask this without being quite direct. But why would you ask someone that when the differences are quite obvious? Certainly between web sockets (bidirectional, client initiated) and HTTP2 push (server initiated, one directional). Are you asking because you basically want to know more about the technologies? In that case why not frame it like that?
- deleted 2y ago[deleted]
- bawolff 2y agoHTTP2 is to hide connection latency by preloading. The other things are for bidirectional communication with a server. I would consider them very much apples and oranges. Its not just that they are designed for different purposes; i don't think it is possible to even use server push for the purpose websockets is used for in the browser.