mach icon indicating copy to clipboard operation
mach copied to clipboard

mach.gzip only compresses text/js/json?

Open nicholascloud opened this issue 9 years ago • 3 comments

Is there a reason that mach.gzip only compresses text/js/json responses? What about media such as images, or other text formats, such as XML (yeah yeah, I know, but it could happen...)?

nicholascloud avatar Mar 31 '15 13:03 nicholascloud

Is there a reason that mach.gzip only compresses text/js/json responses?

Not really. We should probably loosen up the test regex to let it accept more types. I haven't spent a lot of time thinking about it, honestly.

We should also probably let mach.gzip accept a test function as an option so people can override the default test, e.g.

app.use(mach.gzip, {
  test: function (conn) {
    return true;
  }
});

mjackson avatar Mar 31 '15 16:03 mjackson

Related: http://stackoverflow.com/questions/20206771/express-with-node-js-not-compressing-jpeg-images

mjackson avatar Mar 31 '15 16:03 mjackson

@mjackson cool, I'll take a look at tweaking this and submit a PR soon. Good SO find too.

nicholascloud avatar Mar 31 '15 17:03 nicholascloud