4 ms·
Ask HN: What content types do you gzip and why?
I am currently using gzip * at level 9. Standard advice seems to be, do not compress graphics files and PDFs.
I read moot's post yesterday about saving a few transmission bytes and I did an experiment. I got some pages from 6 big web sites and saved all the files and http headers. From the Content-Encoding in the headers they do not seem to gzip any graphics files. When I measured the file sizes with and without compression I found gzip on level 9 gave a total 1.36% saving on JPG, 1.1% on PNG and 6.95% on GIF. Particularly the larger GIFs were worth compressing. I tried excluding the files which increased in size when 'compressed', this could be done automatically on the server, and it made almost no difference to the totals.
I tried gzip on a couple of random PDF files and they gave big savings.
- nkuttler 13y agoHad you used tools like qpdf, optipng, pngcrush, gifsicle or jpegtran on those files before compressing them?
- CalcHere 13y agoNo I just used gzip on maximum against the graphics files I was given by the pages on the major web sites. I did not try to optimize them before the gzip. The two PDF files were just random ones on my computer, not sure where they came from.