Nginx – Which is better: Nginx compression or Apache Compression

apache-2.2compressionnginx

I have an nginx reverse proxy in front of my apache server.

How should I configure compression (gzip or deflate) to serve my website? Should it be from nginx or from mod_deflate from apache? My primary concern is performance and memory usage.

Best Answer

Both represent the same compression algorithm with a different format (gzip adds checksums). There is a similar question with a couple of good answers here.

There is a web service testing compressed sites and showing the compression ratio if you are interested in this kind of data. Although the data is not going to be comparable among different pages - the compression ratio depends on the properties of input data.

Edit: additionally, the compression level is configurable - Apache has the DeflateCompressionLevel directive for configuring this.

Edit #2: Nginx has the gzip_comp_level directive for the same purpose (thanks Alaz)

And just in case it was not clear enough yet: given the same input data and the same compression level setting, you will see virtually the same compression ratio with both implementations (give or take a few bytes for the gzip checksums)