Often someone in the group asked, the picture really need to enable gzip compression? I answered more than once that the picture is not required to enable gzip compression. Today, I write this issue, to analyze why the picture does not need to enable gzip compression.
Picture enabling gzip compression can backfire
Some developers use HTTP to compress files that have already been compressed locally, and those files that have been compressed are not able to perform high-performance when they are compressed again by gzip, as shown in the following two areas.
First, HTTP compression requires cost. The Web server gets what it needs, then compresses it, and finally sends it to the client. If the content can't be further compressed, you're just wasting the CPU doing meaningless tasks.
Secondly, the use of HTTP compression has been compressed things do not make it smaller. In fact, adding headers, compressing the dictionary, and verifying the response body actually makes it larger, as shown in the following illustration:
HTTP Compression process
Does your site actually do this? Yes, it's more common than you think.
The consequences of enabling gzip compression for PNG pictures
The following is a PNG image with gzip compression enabled to see its header information:
The consequences of enabling gzip compression for PNG pictures
Not only waste the CPU, but also increase the volume of the picture, before also wrote a detailed analysis of the "Picture gzip compressed volume after the larger", here to see the picture is the consequences of gzip compression:
Gzip Pictures Increase the volume
In a word to conclude that is the picture enable gzip compression, not only waste the CPU, but also increase the volume, will affect the performance of the server, affecting the speed of the site. Do you want to enable gzip compression for the picture? Absolutely not!