nodejs express: compression of response doesn't work
compression, express, gzip, http, node.js
Solution
Move compress to be the first item after `view item`. Also, be sure to clear cache before checking the Chrome network tag to look for the Encoding header.
Problem
I'm trying to serve compressed views with NodeJS/Express. Even if I configured properly the app, there is no trace of compression. Only static file are compressed. If I access a view in Chrome, I cannot find the field `Content-Encoding: gzip`. The following is configuration of my Express app: ``` app.set('port', process.env.PORT || 3000); app.set('views', __dirname + '/views'); app.engine('html', ejs.renderFile); app.set('view engine', 'ejs'); app.use(express.favicon()); app.use(express.logger('dev')); app.use(express.bodyParser()); app.use(expressValidator()); app.use(express.methodOverride()); app.use(express.staticCache()); app.use(gzippo.staticGzip( path.join(__dirname, 'public') ,{maxAge:86400000} )); app.use(gzippo.compress()); //app.use(express.compress()); app.use(app.router); ``` Note that I'm using gzippo for compression. However also the basic compression `express.compress()` doesn't work.