新增的章节。
If you are not using HTTP/2, then you are losing out on big improvements.
HTTP/2相比http/1有很大的区别。例如:
- multiplexing 多路复用
- server push of assets
如果您没有用HTTP/2优化代码,那么您的应用程序可能比使用HTTP/2要慢。
大量http/1的网页优化实际已经不需要了,甚至它们可能会伤到HTTP/2。
本章介绍一些主要功能,你需要阅读它并跟着它进行更多的在线阅读。
相关连接:
https://nodejs.org/api/http2.html
http://expressjs.com/en/4x/api.html
Brief Overview of HTTP/2
- 多路传输Multiplexing: Allows browsers to include multiple requests in a single TCP connection that enables browsers to request all the assets in parallel.
- 服务器推送Server push: Servers can push web assets (CSS, JS, images) before a browser knows it needs them, which speeds up page load times by reducing the number of requests.
- 流优先Stream priority: Allows browsers to specify priority of assets. For example, a browser can request HTML first to render it before any styles or JavaScript.
- 头压缩Header compression: All HTTP/1.1 requests have to have headers which are typically duplicate the same info, while H2 forces all HTTP headers to be sent in a compressed format.
- De facto mandatory encryption: Although the encryption is not required, most major browsers implement H2 only over TLS (HTTPS).
作为web开发者需要知道的是:
原先的大多数优化计策已经不需要了。尤其是文件串联the file concatenation。
Stop doing that (image sprites, bundled CSS and JS), because H2 can make parallel requests and because each small change in your big file will invalidate cache.
It’s better to have many small files with H2.
I hope the need for build tools like Grunt, Gulp, and Webpack will drop because of that.
Don’t do domain sharding in HTTP2.
请学习所有的HTTP/2细节,可以从这篇文章开始:https://http2.github.io/faq/
SSL Key and Certificate
当浏览一个https网页,地址栏上有一个