New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
More advanced compression "filter" #29
Comments
That is zlib's concern, I believe. |
The way you can do this is simply to wrap this middleware, just like any middleware. Simple example: var compression = require('compression')
var express = require('express')
express.use(variableCompression())
function variableCompression() {
var compressors = Object.create(null)
return function (req, res, next) {
if (!should_compress) { // should_compress is up to you
next()
return
}
var level = get_compression_level() // get_compression_level is up to you
var compressor = compressors[level] || (compressors[level] = compression({level: level}))
compressor(req, res, next)
}
} |
@dougwilson thanks for the start, does zlib handle any of that, or I have to? Any ideas on how to get memory consumption percentage through node? |
I really don't know :/
I've never tried to do that, so I'm not sure off-hand. There is an |
@dougwilson thanks for the help! |
No problem :) Feel free to continue to ask follow ups on this issue, btw. |
Some compression libraries will lower the compression level and even stop compressing if the memory consumption gets too high, and then they will start compressing again once the system has calmed down. Is there something available like that here?
The text was updated successfully, but these errors were encountered: