I ma using express and compression library:
var compression = require('compression')
var express = require('express')
var app = express()
// compress all requests
app.use(compression())
Question:
- How can I just add a gzip response for a single route?
You can inline it, as with any other middleware:
app.get('/route', compression([OPTIONS]), function(req, res) {
...
});
Be aware that the compression middleware maintains a default threshold of 1KB of data, below which responses won't be compressed. See the documentation on how to change this if required.
- If may server is IIS 8 which is host at Azure web app, will compression work?
I would assume so, but can't state definitively as I don't have any IIS/Azure experience. But why not try it out?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With