forked from facebook/hhvm
-
Notifications
You must be signed in to change notification settings - Fork 0
Setting the content encoding for static files
Simon Welsh edited this page Sep 4, 2013
·
1 revision
There are certain file types that are stored and sent as gzipped files, but should be served with a non-gzip content-type. In this cases, a content-encoding header is required to tell the browser that it is a gzipped file but you don't want the server to gzip the file again. To do this, you need to add both the mime-type for the extension and then the content-encoding header.
For example, the svgz extension denotes a gzipped SVG file. It should be served with a content type of image/svg+xml
and a content encoding of gzip
. This is done using the StaticFile.Extensions
configuration options to set the content type and StaticFile.FilesMatch
configuration option to add the encoding header.
An example config extract is:
StaticFile {
Extensions {
svgz = image/svg+xml
}
FilesMatch {
* {
pattern = \.svgz$
headers {
* = Content-Encoding: gzip
}
}
}
}