expressjs / compression

Node.js compression middleware
MIT License
2.77k stars 241 forks source link

compression gzip not working (expressjs - compression library) #95

Closed alirezavalizade closed 8 years ago

alirezavalizade commented 8 years ago

I use from compression library and still not working.. this is my config :

const app = express();

app.use(compression());

app.use("/public", express.static(path.join(path.resolve(__dirname, '../../public'))));

noat4

dougwilson commented 8 years ago

By default, this module does not compress responses that contain already compressed assets, like JPEG images. You can use the filter option to override this behavior if you like.

alirezavalizade commented 8 years ago

@dougwilson can you show me How?

dougwilson commented 8 years ago

Unfortunately I am on a phone, and it's impractical to type code here. You can see the documentation for filter at https://github.com/expressjs/compression/blob/master/README.md#filter and there is a filter override example in the readme as well. If you want to simply compress all types, just return false in the function.

dougwilson commented 8 years ago

just return false in the function.

I meant to type return true.

dougwilson commented 8 years ago

Hi @alirezavalizade I'm not sure I understand.

dougwilson commented 8 years ago
app.use(compression({
  filter: function () { return true; }
}));