Search code examples
node.jsexpresshttpsocket.iohttp2

http2 in node.js, express, socket.io client


I am building a web app that uses a express and node.js in the backend. In my server.js file, I have the following code

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); instead?

If I switch to http2, is there anything else I need to specifically change that wasn't present in http1? And is the way of sending HTTP requests such as get or post any different from http1 to http2?


Solution

  • HTTP2 is more efficient and loads faster pages-Differences. But I suggest you use https since its more secure and most of the browsers mark non https requests as insecure. similar stack