Compression for Express is commonly used to compress the size of your code files in Express apps. It is a middleware. It does not compress other files such as images.
Generally compression is also provided by your server provider. But in case they do not, this is a easy and sure way to send compressed program files to the client, making your website run faster.
Generally compression is also provided by your server provider. But in case they do not, this is a easy and sure way to send compressed program files to the client, making your website run faster.
HOW TO INSTALL?
Install Compression using Node Package Manager (NPM)
npm install --save compression
HOW TO INCLUDE?
Include Compression in your application in the following way in the main app.js/server.js
const compression = require('compression');
HOW TO USE?
Finally use it as a middleware after creating express instance.
app.use(compression());
Comments
Post a Comment