3 ms·
People often seem to think that HTTP/2 Push was a good thing that could let you improve performance. It really wasn’t. As a performance optimisation tool, it a
by chrismorgan 6y ago
People often seem to think that HTTP/2 Push was a good thing that could let you improve performance.
It really wasn’t. As a performance optimisation tool, it absolutely depended upon cache digests to make any sense, but cache digests were never finished, and so push became a wild guess that would routinely be a pessimisation instead of an optimisation: “why did you clog my pipe up, sending me that megabyte of JavaScript? I already had it!”
“But this helped webpack and other such bundlers”—this was never actually true. Even if cache digests had materialised, almost every situation that PUSH frames could have helped with in JavaScript bundling would be better or at least similarly handled in a different way: if you need the resource immediately, you were probably splitting your bundle up too small and should merge the files (though this is certainly not always the case; there are definitely cases where cache digests + push could have done a better job); and if you don’t need the resource immediately, <link rel=preload> is much of a muchness with the push frames, but allows the client to retain control of what it fetches when, which is normally a mildly desirable property; or a service worker could also directly interact with the cache, too.
I think it was the other purposes of PUSH frames that were more interesting in their technical possibilities, things like letting APIs kinda return multiple responses to a request. But those possibilities never really eventuated, because once you’re doing things like that, streaming response bodies and WebSockets are mostly easier and definitely more reliably available—though you may end up reimplementing a few pieces of HTTP/2 Push along the way, depending on your use case.
So all up, I say of it all that yeah, it was a nice idea, but it ended up just not being useful in practice, because its use cases all either depend on something else that doesn’t exist, or are at least as well handled by something else.
I haven’t followed any discussions around this, but as a developer that’s not at all fond of Google my feeling and expectation is that it’s not really “Chrome dictates the direction of the web and they’ve unilaterally killed it” here so much as a general consensus of “we thought this thing would be great, but it didn’t really pan out, and it makes things quite a bit more complex and no one should be actually depending on it, so we’re removing it”—and Google is just the first one to actually do so. I think the average developer here is just thinking that HTTP/2 Push is better and more useful than it actually is.
- treve 6y agoGreat summary. We indeed switch to Websockets for a few things that we would like to have (eventually) used HTTP/2 Push for. To give an example of an issue with this, is that we would like to receive updated resource states when they happen. Receiving these via websocket unfortunately means that they can't really interact with the browser cache, which led us to implementing our own Javascript caching layer. There's many small examples of this where the ideal approach doesn't exist yet, and we're left to imperfect workarounds.
- TomAnthony 6y agoThis makes sense. What makes less sense is why cache digests were abandoned and not finished? Surely that would have made Push useful?
- LoSboccacc 6y agothere's still one area where it kind of mitigates another issue, which is making sure fonts are on the client by the time text is visible, idk what's the status now but last time I checked, admittedly more than a year ago, there weren't much other options to at least reduce the flicker.