高级前端http【Q109】可以对图片开启 gzip 压缩吗,为什么

可以对图片开启 gzip 压缩吗,为什么

Issue 欢迎在 Gtihub Issue 中回答此问题: Issue 110

Author 回答者: shfshanyue

不需要开启,如果开启的话,有可能使图片变的更大。如果你注意一些网站的 img 资源时,就会发现他们都没有开启 gzip

参考: https://webmasters.stackexchange.com/questions/8382/is-gzipping-images-worth-it-for-a-small-size-reduction-but-overhead-compressing

Don’t use gzip for image or other binary files.

Image file formats supported by the web, as well as videos, PDFs and other binary formats, are already compressed; using gzip on them won’t provide any additional benefit, and can actually make them larger. To compress images, see Optimize images.