HTTP2 Trial Little Note

Source: Internet
Author: User

Original: https://www.clarencep.com/2016/11/17/upgrade-nginx-to-support-http2/

These two days to upgrade the Company's website to the whole station Https. By the way, HTTP2 's browser support:

The support is also very good. Can not help but try a http2– to take this blog directly to do the Example.

Upgrade Nginx

Mainstream browsers basically support the HTTP2, but nginx only upgrade to more than 1.10 version of the Line-the humble station before the use of a version of Nginx 1.6.

Updated the next apt-get, found that there is no 1.10 version in the warehouse – embarrassing – you have to compile it yourself:

first, Download Nginx and Openssl:

1
2
3
4
5
6
7
cd/usr/LOCAL/SRC

wget https://nginx.org/download/nginx-1.11. 6.tar.gz
Tar xzf nginx-1.11. 6.tar.gz

wget https://www.openssl.org/source/openssl-1.1. 0c.tar.gz
Tar xzvf openssl-1.1. 0c.tar.gz

then, Compile Nginx:

 1 
2
3
4
5
6
7
8
9
10
11
12
13
  
cd nginx- 1.11.6
./configure--prefix=/usr/ local/nginx \
--conf-path=/etc/nginx/nginx.conf \
--with-openssl=. /openssl-1.1. 0c \
--with-http_ssl_module \
# to facilitate global execution, create a symbolic link:
sudo ln -s/usr/local/nginx/sbin/nginx/usr/sbin/ Nginx

then, is the old configuration of the transplant, the old configuration can be directly used, directly copied Over.
finally, enabling http2– currently HTTP2 can only be used with SSL (https), as long as the listen statement is modified:

1
2
3
4
# old Configuration:
# Listen 443;
# New Configuration (enable http2):
443 SSL http2;

Don't forget to restart the Nginx ( sudo nginx -s reload ).

Attempt to access via HTTP2

After the nginx, take a chrome can use HTTP2 –chrome 49 and above support HTTP2, fortunately, Chrome will automatically upgrade, basically don't worry about chrome too old.

Open F12 View the HTTP header, sure enough, the request headers is different:

These :authority , :method and the same as the :path Colon is one of the characteristics of HTTP2-hand without grasping the bag tool, only such superficial judgment.

Look at HTTP2 's water:

And the water of HTTP1.1:

HTTP2 Water is more concise, there is no!

Performance PK

HTTP2 performance should generally be higher than the HTTP1.1, but it is not necessarily yo:

is the first page of this blog in the same nginx, the same pc, the same network conditions on the HTTP2 and HTTP1.1 respectively tested PK Results. Although HTTP2 's Network load time (load) is shorter than HTTP1.1, Dom render time (domcontentloaded) is longer than HTTP1.1 ...

May be due to the BO is not specifically for HTTP2 Optimization. It is also possible that browser rendering is not optimized for HTTP2.

Finally summed up a sentence: HTTP2 into the pit to be cautious.

HTTP2 Trial Little Note

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.