httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Artur Zaprzala <>
Subject *.gz files shouldn't get "Content-Encoding: gzip" header
Date Thu, 11 Jul 2002 09:23:02 GMT
*.gz files get the following headers:
Content-Type: application/x-gzip
Content-Encoding: gzip

According to RFC2616 these headers should be interpreted in the 
following way: to get application/x-gzip media-type from the response 
body, gzip decoding mechanism must be applied. But after decoding gzip, 
media type will be no longer application/x-gzip. So these headers are 

Here is the relevant RFC2616 fragment:
14.11 Content-Encoding

     The Content-Encoding entity-header field is used as a modifier to the
     media-type. When present, its value indicates what additional content
     codings have been applied to the entity-body, and thus what decoding
     mechanisms must be applied in order to obtain the media-type
     referenced by the Content-Type header field. Content-Encoding is
     primarily used to allow a document to be compressed without losing
     the identity of its underlying media type.

The default Apache config files contain the following directives (I 
checked versions from 1.2.6 through 2.0.39), which should be removed 
(maybe there is a better solution?):
# AddEncoding allows you to have certain browsers (Mosaic/X 2.1+) uncompress
# information on the fly. Note: Not all browsers support this.
# Despite the name similarity, the following Add* directives have nothing
# to do with the FancyIndexing customization directives above.
AddEncoding x-compress Z
AddEncoding x-gzip gz tgz

I see from the comments that the intention was to make some browsers 
uncompress *.gz, *.tgz and *.Z files on the fly, but generally this is 
not expected behaviour, and current browsers (e.g. Mozilla) have 
workarounds for this "feature".

Some examples of Apache behaviour:
For foo.gz.html:
Content-Type: text/html
Content-Encoding: gzip
This is correct, though the filename is strange.

For foo.html.gz:
Content-Type: application/x-gzip
Content-Encoding: gzip
This is wrong: after removing gzip encoding, Content-Type will be 
text/html, not application/x-gzip.

The way it should be:
For foo.html.gz or foo.gz:
Content-Type: application/x-gzip
Content-Encoding: identity

Artur Zaprzala

View raw message