Practical Node.js (2018版) 13章, Node HTTP/2 Servers

时间:2022-01-16 06:05:16

新增的章节。

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网页,地址栏上有一个

Practical Node.js (2018版) 13章, Node HTTP/2 Servers的更多相关文章

  1. Practical Node.js (2018版) 14章, async code in Node

    Asynchronous Code in Node 历史上,Node开发者只能用回调和事件emitters. 现在可以使用一些异步的语法: async module Promises Async/aw ...

  2. Practical Node.js (2018版) 第7章:Boosting Node.js and Mongoose

    参考:博客 https://www.cnblogs.com/chentianwei/p/10268346.html 参考: mongoose官网(https://mongoosejs.com/docs ...

  3. Practical Node.js (2018版) 第5章:数据库 使用MongoDB和Mongoose,或者node.js的native驱动。

    Persistence with MongoDB and Mongoose https://github.com/azat-co/practicalnode/blob/master/chapter5/ ...

  4. Practical Node.js (2018版) 第10章:Getting Node.js Apps Production Ready

    Getting Node.js Apps Production Ready 部署程序需要知道的方面: Environment variables Express.js in production So ...

  5. Practical Node.js (2018版) 第9章: 使用WebSocket建立实时程序,原生的WebSocket使用介绍,Socket.IO的基本使用介绍。

    Real-Time Apps with WebSocket, Socket.IO, and DerbyJS 实时程序的使用变得越来越广泛,如传统的交易,游戏,社交,开发工具DevOps tools, ...

  6. Practical Node.js (2018版) 第3章:测试/Mocha.js, Chai.js, Expect.js

    TDD and BDD for Node.js with Mocha TDD测试驱动开发.自动测试代码. BDD: behavior-driven development行为驱动开发,基于TDD.一种 ...

  7. Practical Node.js (2018版) 第8章:Building Node.js REST API Servers

    Building Node.js REST API Servers with Express.js and Hapi Modern-day web developers use an architec ...

  8. 《深入浅出Node.js》第1章 Node简介

    @by Ruth92(转载请注明出处) 第1章 Node简介 一.Node的起源 高性能Web服务器的要点:事件驱动.非阻塞I/O. 选择JavaScript的原因:高性能.符合事件驱动.没有历史包袱 ...

  9. Practical Node.js (2018版) 第4章: 模版引擎

    Template Engines: Pug and Handlebars 一个模版引擎是一个库或框架.它用一些rules/languages来解释data和渲染views. web app中,view ...

随机推荐

  1. 106运用SWITCH语句打印星期几的单词

    package com.chongrui.test;/*运用SWITCH语句打印星期几的单词 * */ public class TypeConvertion { public static void ...

  2. js动态的把左边列表添加到右边,可上下移动。

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

  3. mysql之TIMESTAMP(时间戳)用法详解 &lbrack;http&colon;&sol;&sol;www&period;jb51&period;net&sol;article&sol;51794&period;htm&rsqb;

    一.TIMESTAMP的变体 TIMESTAMP时间戳在创建的时候可以有多重不同的特性,如: 1.在创建新记录和修改现有记录的时候都对这个数据列刷新: TIMESTAMP DEFAULT CURREN ...

  4. QT编程环境搭建

    使用QT需要QT的库以及QT creator,在QT5以后的版本中,两者已经集成,不需要单独下载了,只需要下载一个文件即可.配置步骤如下: 1.下载qt-opensource-windows-x86- ...

  5. Leetcode 28——Implement strStr&lpar;&rpar;

    Implement strStr(). Return the index of the first occurrence of needle in haystack, or -1 if needle ...

  6. sklearn:最近邻搜索sklearn&period;neighbors

    http://blog.csdn.net/pipisorry/article/details/53156836 ball tree k-d tree也有问题[最近邻查找算法kd-tree].矩形并不是 ...

  7. jpa无外键配置

    在用jpa这种orm框架时,有时我们实体对象存在关联关系,但实际的业务场景可能不需要用jpa来控制数据库创建数据表之间的关联约束,这时我们就需要消除掉数据库表与表之间的外键关联.但jpa在处理建立外键 ...

  8. App案例分析——XBMC

    本文分析app的是安卓本地视频播放器:XBMC. 第一部分: 调研,评测 1.下载软件并使用起来,描述最简单直观的个人第一次上手体验.   第一次使用这个播放器,就很喜欢这个主界面,其他类似软件的主界 ...

  9. ASP&period;NET Core使用NLog记录日志

    1.根目录新建nlog.config配置文件 <?xml version="1.0"?> <nlog xmlns="http://www.nlog-pr ...

  10. iOS之ShareSDK各社交平台申请AppKey的网址及申请流程汇总

    平台 开放平台地址 APPkey 申请流程 新浪微博 http://open.weibo.com http://bbs.mob.com/thread-89-1-4.html 新浪微博开放平台接入tip ...