Node.js gzip compression

It seems to me like node.js as a brand new project is always set to have gzip compression always enabled as default, however for some reason when I run my site through a tool like pingdom it says gzip compression is not actually on.

On lines 26-29 of /lib/server.js has this as a conditional, so if it is always on, then why have it as a condition?

Am I meant to do something more to fully activate it?


Default compression is enabled by default. You can disable it for when your node is running behind a proxy which does the compression.

Also be aware, while we always enable compression, your hosting probably has a proxy in front of the node server which perhaps has no compression. A common setup is to have no compression on the node server and have a nginx server in front of the node server as reverse proxy and for handling the static files and doing the compression.

1 Like