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/

Daniel Stenberg
  • 54,736
  • 17
  • 146
  • 222
Merik C.
  • 253
  • 1
  • 3
  • 8

4 Answers4

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.

Daniel Stenberg
  • 54,736
  • 17
  • 146
  • 222
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.

Patrick Collins
  • 4,046
  • 3
  • 26
  • 29
  • 1
    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. – StephenKing Mar 17 '17 at 10:27
  • @StephenKing 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. – Patrick Collins Mar 20 '17 at 06:08
  • 8
    I love how Owen said "usage has been low from web developers" - isn't this _because_ Nginx doesn't support it?! – developius Apr 12 '17 at 11:05
4

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

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

Andrew Joe
  • 141
  • 4
  • 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: https://ops.tips/blog/nginx-http2-server-push/ – Ciro Costa Feb 13 '18 at 20:15
-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

Archimedes Trajano
  • 35,625
  • 19
  • 175
  • 265