Effects of gzip_comp_level on HTML: Tweaking Nginx's GZIP settings
The Nginx GZIP Module allows you to specify the compression level—trading off CPU time compressing versus network bandwidth—by setting
gzip_comp_level to a value of 1 through 9. The following graph shows the effects of the nine different compression levels:
Each line represents the effects on a different HTML file. As we can see, large files tend to compress better as a percentage of the overall size, particularly on files with repetitive content. (The largest two files were the lists of all objects (42k) and properties (462k) in ObjJob, which have many items with similar markup.)
There are only small gains from each compression level above 1. Following is the table of file sizes and the original URLs from which they were obtained:
Based on these results, I’ve set my own server at
gzip_comp_level 5;. I have plenty of CPU time to spare these days.
It would be interesting if someone were to perform this analysis and pair it with the actual CPU impact and processing time for the various settings.