4

I've been testing HTTP2 Multiplexing and HTTP2/Server Push in Node.js locally and inspected it in the waterfall network graph in Chrome Dev Tools. While using my own Node.js Server Push with res.stream.pushStream I got an "Initiator: Push (index)" in DevTools like this:

The change was noticeable as below: nicely pushed


I did some more research and figured I should use a reverse proxy to do the job (for example Nginx instead) and connect to my Node.js via HTTP1.1 instead as the upstream and serve HTTP2 from my reverse proxy. After setting up the nginx.conf with http2_push_preload on; i sent some headers like these from my Node.js backend:

res.setHeader("Link","</picture.jpg>; as=image; rel=preload");

To my suprise I didn't see the "Push / (index)" indicator but "Other" like on the screenshot below and the asset listed in the link header seemed to show up on the waterfall graph quicker with a slightly lower TTFB time compared to the rest of assets.

initiator - other

I've been also looking for a solution to serve HTTP/2 as the reverse proxy and to download the assets via HTTP/2 from the service directly without the TLS (HTC) but it seems there's nothing like this.

Getting back to my question: How should I go about testing the HTTP/2 Server Push? Is the "Initiator: Other" a misinterpretation from the devtools? It seems to be working but it doesn't report as Server Push.

Also, are there any projects/solutions that would let for a connection to a backend upstream via HTTP2 directly?

I'm pretty sure the latter image shows slower access because of the overhead of using a reverse proxy instead of connecting to the server directly and it's magnified by the HTTP1.1 usage on the target server.

Jonas
  • 121,568
  • 97
  • 310
  • 388
Dawid
  • 585
  • 5
  • 26
  • 1
    That isn’t working. You can see the white and then green request time as well as the blue download time. With push you should only see the blue download time. It seems Nginx is not recognising the push instruction and Chrome is preloading this resource instead. What version of nginx are you using? Are you using a self-signed cert for HTTPS or a recognised cert (do you have a red crossed out padlock)? – Barry Pollard Jan 05 '20 at 09:08
  • It's a self signed certificate, so it's a red lock and I'm currently on nginx 1.16.0 (http2 push should work since 1.13.9) – Dawid Jan 05 '20 at 11:33
  • HTTP/2 push doesn’t work with a red padlock in Chrome. You need to accept the cert to your trust store or use a cert issued by a recognised cert authority and then it should work. I presume your node cert was different? – Barry Pollard Jan 05 '20 at 11:35
  • Actually it was the same cert, so it's probably not it – Dawid Jan 05 '20 at 11:36
  • Okay, I reloaded the whole system again (no tweaks whatsoever, just a hard reset) and it caught up and seems to work with Push / Other right now. I'll do some more debugging and try to figure out if I can reproduce the bug. Thanks for following along – Dawid Jan 05 '20 at 11:45

1 Answers1

0

Thanks to @Barry I figured out it's actually Chrome itself as the "Other" initiator and it indeed speeds up the process a bit by using the Resource Hints Link header and not HTTP/2 Server Push itself. The problem was actually a bug I can't seem to reproduce and it works well after a restart of the OS. Afterall Nginx was the culprit of not using the headers correctly, which kicked in when parsed in Chrome.

Dawid
  • 585
  • 5
  • 26