Does the nginx HTTP/2 module support Server Push?
Asked Answered
B

4

15

I'm planning to upgrade my nginx to 1.9.6 which supports HTTP/2.

Have nginx implemented HTTP/2 server push?

ref: https://ma.ttias.be/service-side-push-http2-nghttp2/

Backstroke answered 5/11, 2015 at 5:17 Comment(0)
E
20

Yes, Nginx supports HTTP/2 server push since version 1.13.9, released on February 20, 2018.

The Nginx team pointed out in the original 1.9.5 blog post that it wasn't supported back then.

Eureka answered 8/11, 2015 at 22:41 Comment(2)
As of v 1.11.4 on 13 Sep 2016, this is still true.Sumerlin
Any news on when server push will be added to nginx? Waiting for this so badly...Badr
U
14

Edit:

Nginx supports HTTP/2 server push since v1.13.9, released on February 20, 2018.

Older answer:

Nginx does not support HTTP/2 server push as of March 2017 (v1.11).

Owen Garrett at nginx has summarized the reasons as follows:

  • it is a non-essential and optional part of http/2

  • if the client already has the resource cached, then by pushing it to them you might be unnecessarily wasting bandwidth.

  • server push spec might change in the future.

  • Link headers as hints is useful, but usage has been low from web developers.

  • server push has been available as part of SPDY and was not utilized by many web developers.

Read his original comments here. This table accurately describes the pro's and con's of server hints vs server push.

Personally this disappoints me because I think this would be a valuable feature for web developers willing to invest the time to optimize page speeds. I also know that some large CDN's like Cloudflare have implemented their own version within nginx to optimize page downloads.

Ulceration answered 2/3, 2017 at 21:8 Comment(3)
It's not really so much a waste of bandwidth as one might think. The headers for the pushed objects are sent first (prior to the requested page) so that the client should have some time to cancel server pushes.Conney
@Conney if server push were implemented, the client probably wouldn't get a chance to reset before the frames relating to the server pushes had already arrived. So it probably is wasteful. However, there are several obvious solutions to not pushing assets that are likely to be cached including the use of cookies and simple log history.Ulceration
I love how Owen said "usage has been low from web developers" - isn't this because Nginx doesn't support it?!Daina
S
4

Support for http/2 server push has been added to nginx as of Feb 8th, 2018:

https://hg.nginx.org/nginx/rev/641306096f5b

Sika answered 13/2, 2018 at 18:1 Comment(1)
I just gave a try, works great - you can set for your static content (server by NGINX directly) as well as backends (as long as the backend advertise the links via Link header). I documented what I learned here: ops.tips/blog/nginx-http2-server-pushRustication
G
-5

You need to pay for it with an nginx plus subscription https://www.nginx.com/blog/http2-r7/.

Apache provides it for free

https://httpd.apache.org/docs/2.4/mod/mod_http2.html#h2push

Greenbrier answered 23/8, 2016 at 6:14 Comment(3)
From your URL: "The “Server Push” feature defined in the HTTP/2 RFC is not supported in this release. Future releases of NGINX Plus might include it."Chungchungking
There are two URLs I have posted which one states it does not support it?Greenbrier
From the first link: "The “Server Push” feature defined in the HTTP/2 RFC is not supported in this release. Future releases of NGINX Plus might include it."Chungchungking

© 2022 - 2024 — McMap. All rights reserved.