Chapter 6. MIME, Content and Language Negotiation
Apache has the ability to tune its returns to the abilities of the
client -- and even to improve the client's efforts.
Currently, this affects:
The choice of MIME type returned. This is often used for images,
which might be the very old-fashioned bitmap, the old-fashioned
.gif, or the more modern and smaller
.jpg. Apache's reactions can be extended
and controlled with a number of directives. The language of the returned file. Updates to the returned file. The spelling of the client's requests.
6.1. MIME Types
MIME stands for Multimedia Internet Mail
Extensions. The code used here is in mod_mime.c
and is compiled in by default. It allows Apache to determine the type
of a file from its extension. The list of MIME types that Apache
already knows about is distributed in the file
..conf/mime.types or can be found at
http://www.isi.edu/in-notes/iana/assignments/media-types/media-types.
You can edit it to include extra types, or you can use the
directives discussed in this chapter. The default location for the
file is .../<site>/conf, but it may be
more convenient to keep it elsewhere, in which case you would use the
directive TypesConfig.
Changing the encoding of a file with one of these directives does not
change the value of the Last-Modified header, so
cached copies can be used. Files can have more than one extension,
and their order normally doesn't matter. If the extension
.itl maps onto Italian and
.html maps onto HTML, then the files
text.itl.html and text.html.itl
will be treated alike. However, any unrecognized
extension, say .xyz, wipes out all extensions to
its left. Hence text.itl.xyz.html will be
treated as HTML but not as Italian.
6.1.4. AddEncoding
AddEncoding mime-enc extension extension
Anywhere
This directive adds new types of encoding to the list. Hence:
AddEncoding x-gzip zip
will cause Apache to send x-gzip as the encoding
for files with the extension .zip so that a file
stuff.zip will automatically be unzipped as it
is served.[50] For compatibility with older
browsers, the prefix x- is specially handled, so
that x-gzip is functionally the same as
gzip. This is because the
browser can say what it is prepared to handle with an
Accept-Encoding header. If it says
gzip, then Apache will send
gzip, even if you've set
x-gzip; similarly, if it says
x-gzip, then so will Apache. But if the browser
says nothing, Apache will say whatever you set, so you'd better
set the old form (x-gzip) since the browser may
also be old.
[50]Note that browser support for this useful
facility is patchy at best, so, as the saying goes, YMMV (your
mileage may vary).
 |  |  | 5.12. Overrides |  | 6.2. Content Negotiation |
Copyright © 2001 O'Reilly & Associates. All rights reserved.
|
|