Prev Next

Web / NodeJS Interview questions

How do I enable gzip compression for my Node.js express responses?

Use the compression middleware for gzip compression in your Express app. Gzip compressing decrease the size of the response body and hence increase the speed of a web app.

First, install the npm package in your project for compression:

$ npm i compression --save

You can use the module in your application.

var compression = require('compression')
var express = require('express')
var app = express()
app.use(compression())

More Related questions...

Show more question and Answers...


Comments & Discussions