Serving static files, HTTP Compression and MIME types
A typical static file serving Suave application would look somewhat like this,
placed in files.fsx
and serving from ./public
relative to your script file.
The main file combinators are file
, browseHome
and variations of these. To
learn about all of them check out the Files module
documentation
file
will take the relative or absolute path for the file we want to serve to
the client. It will set MIME-type headers based on the file extension.
browseHome
will match existing files in the homeFolder
based on the Url
property and will serve them via the file
combinator; homeFolder
is a
configuration parameter and can be set in the configuration record.
Suave supports gzip and deflate http compression encodings. Http compression is configured via the MIME types map in the server configuration record.
By default Suave does not serve files with extensions not registered in the mime types map.
The default mime types map defaultMimeTypesMap
looks like this.
You can register additional MIME extensions by creating a new mime map in the following fashion.