Serve static files from a Yesod app.
This is great for developing your application, but also for a dead-simple deployment. Caching headers are automatically taken care of.
If you are running a proxy server (like Apache or Nginx), you may want to have that server do the static serving instead.
In fact, in an ideal setup you'll serve your static files from
a separate domain name to save time on transmitting
cookies. In that case, you may wish to use
to redirect requests to this subsite to a separate domain
Note that this module's static subsite ignores all files and
directories that are hidden by Unix conventions (i.e. start
with a dot, such as
".ssh") and the directory tmp on the
root of the directory with static files.
- newtype Static = Static StaticSettings
- data family Route a
- type StaticRoute = Route Static
- static :: FilePath -> IO Static
- staticDevel :: FilePath -> IO Static
- embed :: FilePath -> Q Exp
- staticFiles :: FilePath -> Q [Dec]
- staticFilesList :: FilePath -> [FilePath] -> Q [Dec]
- publicFiles :: FilePath -> Q [Dec]
- base64md5 :: ByteString -> String
Type used for the subsite with static contents.
data family Route a
The type-safe URLs associated with a site argument.
Produce a default value of
Static for a given file
Does not have index files or directory listings. The static files' contents must not change, however new files can be added.
static, but does not assumes that the files do not
change and checks their modification time whenever a request
Static based on embedding all of the static
files' contents in the executable at compile time.
Template Haskell helpers
Template Haskell function that automatically creates routes for all of your static files.
For example, if you used
and you had files
"static/js/script.js", then the following top-level
definitions would be created:
style_css = StaticRoute ["style.css"]  js_script_js = StaticRoute ["js/script.js"] 
Note that dots (
.), dashes (
-) and slashes (
replaced by underscores (
_) to create valid Haskell
staticFiles, but takes an explicit list of files
to create identifiers for. The files path given are relative
to the static folder. For example, to create routes for the
"static/css/normalize.css", you would use:
staticFilesList \"static\" [\"js\/jquery.js\", \"css\/normalize.css\"]
This can be useful when you have a very large number of static files, but only need to refer to a few of them from Haskell.
staticFiles, but doesn't append an ETag to the
publicFiles will speed up the compilation, since there
won't be any need for hashing files during compile-time.
However, since the ETag ceases to be part of the URL, the
Static subsite won't be able to set the expire date too far
on the future. Browsers still will be able to cache the
contents, however they'll need send a request to the server to
see if their copy is up-to-date.