carrot / charge

A bundle of useful middleware and tools for serving static sites
Other
22 stars 1 forks source link

Add compression middleware #13

Closed jescalan closed 10 years ago

jescalan commented 10 years ago

With gzip no longer activating through alchemist, we need a way to make the compression happen. I'm actually kind of glad that this can be a separate piece of middleware, it feels like it belongs that way.

This guy comes with sort of a "secret option" - while most people want to turn on gzip and have everything compressed (which you can do by passing gzip: true as before), you can actually set a threshold for content size, that if exceeded, the content will be gzipped. Pretty nice. You can activate this by passing { threshold: 1000 } to the gzip option rather than a boolean.