Why I should not compress images in HTTP headers?

14,185

Solution 1

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.

Solution 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.

Share:
14,185

Related videos on Youtube

Agusti-N
Author by

Agusti-N

Updated on May 20, 2022

Comments

  • Agusti-N
    Agusti-N almost 2 years

    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?

  • R. Martinho Fernandes
    R. Martinho Fernandes over 13 years
    @Agusti: if your images happen to be uncompressed, like say, .bmp files, you should convert them to .png or .jpg, as appropriate, and then serve the converted version, of course :)
  • Agusti-N
    Agusti-N over 13 years
    @Martinho Fernandes thank you but my images are .png files, btw it's very good to know this tip :-D
  • Skilldrick
    Skilldrick over 13 years
    @Martinho Good point - that was what I meant by "Your images should already be compressed", but it's good to make it explicit.