Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

5
  • 11
    Express 4.x removed almost all middleware, including compress. You can use Connect's compression middleware now: github.com/expressjs/compression. Commented Apr 18, 2014 at 1:55
  • 1
    does it require extra steps in heroku Commented Mar 22, 2015 at 14:42
  • In what circumstances does the compression trigger? I just added it but wrote res.send and no gzipped content came out. Does it require res.end or some other trigger? Commented Apr 26, 2015 at 5:01
  • 3
    Don't forget to add { threshold: 0 } when you want to compress static files with Express 4.x Commented Jun 20, 2016 at 10:05
  • Apart from run time template->html, is it good to use compression for .js and .css if we can compress them? Because it won't be good idea to use for SSR where bcoz of heavy traffic, it would have to compress for each file requested.. Can you please tell how to use compress just for .html? I'm using .ejs for templates.. @Spawnrider Also, I didn't add threshold: 0 for my .css or .js files, it worked right away Commented Jul 16, 2017 at 19:51