Server Push Thru Http2

Server: nginx-1.15.8 downloaded as Pre-Built Packages from

Config: in /etc/nginx, different from nginx-1.9.15, whose config in /usr/local/nginx
Add to server section: listen 444 ssl http2;
Add to location section: http2_push /style.css;

with Chrome: go to
Developer Tools – network: header colum shows h2
with Curl 7.63: curl.exe -vso /dev/null –http2
watch for output: “server accepted to use h2”
Notes: style.css is downloaded both with and without http2. The difference is that without a separate corresponding request from browser, or so called Server Push.


Server Push

There are two kinds of server pushes.

1. video server keeps pushing jpg image frames as a way for browser to play video.

AKA M-JPEG over HTTP, “server push stream”. As a mime-type content type multipart/x-mixed-replace;boundary=boundary-name, the images are separated by boundary-name.

It’s really still a Pull instead of Push because images are sent as one resource in response to GET. The URL looks like this:

2. The other server push is truly a Push. For example, browser request 1.htm, but server returns 2.htm, which browser didn’t request, in addition to 1.htm. This is part of HTTP/2 standard.
Nginx started supporting at version 1.13.9

TCP behind NAT

It’s assumed that host A B both behind NAT, and UDP hole punching is already working.
There are two more requirements for A to initiate a TCP connection to B.
1. natA has to tolerate B’s sending A a SYN by not replying a RST.
2. natB allows A’s SYN to come in, while natB normally expects A’s SYN/ACT.
Most NAT doesn’t meet these two requirements, which explains TCP hole punching seldom works.

Ternary conditional operator is not shortcut of if-else

Reference can be initialized by ?:, but cannot by if-else.
The same is true for const initialization and initialization list on constructors.
Consider this code snippet:

	int a = 0, b = 1, bCondition = false;
	int & c = bCondition ? a : b;
	c = 2;
	_ASSERT(b == 2);
	(bCondition ? a : b) = 3;
	_ASSERT(b == 3);

The root distinction is that ?: is expression but if-else is statement.