4 ms·
How is server push implemented in current nginx? Can nginx itself automatically parse HTML/CSS and send required resources? Is there a mechanism for the proxi
by devit 11y ago
How is server push implemented in current nginx?
Can nginx itself automatically parse HTML/CSS and send required resources?
Is there a mechanism for the proxied application to specify additional resources? (for JavaScript use)
- runesoerensen 11y agoAFAIK Server Push is not supported (it wasn't supported in the `ngx_http_spdy_module` either). This was also mentioned in the alpha patch announcement: HTTP/2's 'Server Push' feature is not supported in this patch and will not be supported in the first production-ready release of the HTTP/2 implementation. This feature might appear in a future NGINX release. [1] [1]https://www.nginx.com/blog/early-alpha-patch-http2/ https://www.nginx.com/blog/early-alpha-patch-http2/
- callum85 11y agoGetting slightly off topic, but I'm confused about an aspect of server push (maybe you can help). Even on HTTP/1, the client typically only downloads assets on the first page load for a given website, then it caches them. Subsequent requests for other pages are much quicker because the assets don't need to be downloaded again. With server push, would the server typically send all linked assets on every request? Or can it somehow keep track of which clients have cached which assets, and avoid wasting bandwidth?
- zimbatm 11y agoYes that would be one possible implementation. It's up to the server and can vary quite a bit depending on the scenario, which is why Nginx hasn't tackled the problem yet. I believe that it's going to take a while to find good heuristics that work in most of the cases. Until then only big companies like Google will have the financial incentive to develop their own custom version that's tailored to their specific use-case.
- gsnedders 11y agoThe browser can cancel the stream after the first "stream open" frame (assuming latency isn't too high, obviously)
- rictic 11y agoOne proposed mechanism for doing server push is for the application server to send Link: rel=preload headers: https://github.com/icing/mod_h2/issues/38 https://github.com/icing/mod_h2/issues/38 Once you've got code running on the client then there's significantly less need for server push, as you can initiate requests in a bunch of ways, XHRs or <img> tags etc. Server push's big win is in getting necessary resources down to the client on the initial page load without waiting for numerous round. As such, you'll see the biggest gains on high latency connections, e.g. mobile.