Score:2

Apache GZIP for images - any reason?

pl flag

JPEG, GIF, PNG and WEBP images are already compressed. Is there any reason to serve them up using GZIP compression, regardless of whether or not the client says it may accept GZIP compression?

curl -H "Accept-Encoding: gzip" -I ^
 https://www.nps.gov/articles/000/images/LATP_Article_TheCalutronGirls.jpg

This HEAD request produces the following headers:

HTTP/1.1 200 OK
Content-Type: image/jpeg
…
Date: Sat, 05 Aug 2023 04:13:29 GMT
Server: Apache
…
Last-Modified: Wed, 04 Jan 2023 21:36:01 GMT
…
Content-Encoding: gzip
…

This server will send images - JPEG, PNG, WEBP - as GZIP. I think it doesn't make any sense at all and is a server misconfiguration, but maybe times have changed and this is now kind of legit … and soon the new normal?

(The fact that the server's clock is off by 58 hours seems to suggest it is not well administered.)

8/8/23: Reported it to the NPS via their contact form.

Score:4
in flag

Adding gzip compression (with default settings) to that particular file does make it slightly (± 1.7 percent) smaller when I compare the 1019174 bytes for the original file versus 1001991 bytes for the gzip compressed version. On that basis using compression is certainly not detrimental and does save "some" bandwidth.
Whether that limited benefit outweighs the CPU cycles required to achieve that compression? I don't know.

Adding compression for CSS, Javascript and HTML content is generally considered much more beneficial though, as evidenced by the numbers in for example: this article which shows that compression achieves 60-80% reduction in the amount of HTML/CSS/JavaScript data that's transferred.

But generally No, it doesn't make sense to compress already compressed data such as JPEG, PNG and most other image formats, nor for any other data that's already compressed such as actual ZIP archives and for example PDF documents.
As this example already showed: you shouldn't be able to achieve much more additional compression by adding a second layer of compression and (the internet consensus is that) in some cases that additional compression may actually make the file slightly larger.

That's why the Apache manual for mod_deflate includes examples of only enabling compression for specific file types and/or excluding certain other types of files.

<Directory "/path/to/html/content">
    # enable compression only for the html files 
    AddOutputFilterByType DEFLATE text/html
</Directory>


<Directory "/path/to/html/content">
   # enable compression for all content 
   SetOutputFilter DEFLATE

   # exclude image files from compression by file extension 
   SetEnvIfNoCase Request_URI "\.(?:gif|jpe?g|png)$" no-gzip
</Directory>
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.