简体   繁体   English

http2 在 node.js,快递,socket.io 客户端

[英]http2 in node.js, express, socket.io client

I am building a web app that uses a express and node.js in the backend.我正在构建一个 web 应用程序,该应用程序在后端使用 express 和 node.js。 In my server.js file, I have the following code在我的server.js文件中,我有以下代码

const express = require("express");
const app = express();
const server = require("http").Server(app);
const io = require("socket.io")(server);

I recently discovered that there is http2 available, should I change the line 3 to const server = require("http2").Server(app);我最近发现有 http2 可用,我应该将第 3 行更改为const server = require("http2").Server(app); instead?反而?

If I switch to http2, is there anything else I need to specifically change that wasn't present in http1?如果我切换到 http2,我是否需要专门更改 http1 中不存在的其他内容? And is the way of sending HTTP requests such as get or post any different from http1 to http2?从http1到http2发送HTTP请求(例如get或post)的方式是否有任何不同?

HTTP2 is more efficient and loads faster pages- Differences . HTTP2 更高效并且加载更快的页面 - 差异 But I suggest you use https since its more secure and most of the browsers mark non https requests as insecure.但我建议您使用 https,因为它更安全,并且大多数浏览器将非 https 请求标记为不安全。 similar stack 类似堆栈

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM