Why I should not compress images in HTTP headers?

我只是一个虾纸丫 提交于 2019-11-30 22:17:05

问题


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?


回答1:


Your images should already be compressed - any extra compression won't have any noticeable effect on filesize, but will increase processing time.

  • .png files use DEFLATE compression already.
  • .jpg files generally use lossy compression.
  • .gif files use LZW compression.

Compressing files that have already been compressed very rarely results in a reduction in filesize, and can often increase filesize.




回答2:


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.



来源:https://stackoverflow.com/questions/4957172/why-i-should-not-compress-images-in-http-headers

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!