为什么我不应该压缩 HTTP 标头中的图像?
我读了一些关于 HTTP 标头压缩的文章。今天我安装了 YSlow,它建议我压缩资源(文本/html、javascript、css 和图像)。现在我正在阅读 Apache mod_deflate 的文档,但在示例中不不压缩图像。
我应该还是不应该压缩网站中的图像?
I read some articles about HTTP headers compression. Today I installed YSlow and it recommends that I compress the resources (text/html, javascript, css and images). Now I'm reading the documentation for Apache mod_deflate but in the example don't compress images.
Should I or should I not compress images in my site?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您的图像应该已经被压缩 - 任何额外的压缩不会对文件大小产生任何明显的影响,但会增加处理时间。
压缩已经压缩的文件很少会导致文件大小减小,并且通常会增加文件大小。
Your images should already be compressed - any extra compression won't have any noticeable effect on filesize, but will increase processing time.
Compressing files that have already been compressed very rarely results in a reduction in filesize, and can often increase filesize.
GIF、JPEG 或 PNG 等图像已通过高度专业化的算法进行压缩,这些算法比 deflate 等通用算法获得更好的结果。
因此,重新压缩它们几乎不会增加文件大小,甚至可能使文件变得更大,同时增加服务器端处理的成本。
所以,换句话说......不要压缩图像。
Images such as GIF, JPEG or PNG are already compressed via highly specialized algorithms that achieve better result than general purpose algorithms such as deflate.
Therefore, re-compressing them yields little to no gain in size, and can even make files bigger, with the added cost of server-side processing.
So, in other words... do not compress images.
SVG 应由 Apache mod_deflate 压缩,
更多信息请参见 https://httpd.apache.org/docs/2.4/mod/mod_deflate.html。
SVGs should be compressed by Apache mod_deflate as
More information at https://httpd.apache.org/docs/2.4/mod/mod_deflate.html.