var compression = require('compression')
var express = require('express')
var app = express()
app.use(compression({filter: shouldCompress}))
function shouldCompress (req, res) {
if (req.headers['x-no-compression']) {
// don't compress responses with this request header
return false
}
// fallback to standard filter function
return compression.filter(req, res)
}
看文档啊, 使用实例都给你了,不需要nginx配合,express自己就能干。
https://github.com/expressjs/...