wai-middleware-etag-0.1.0.0: WAI ETag middleware for static files

Copyright(c) 2014 Andreas Meingast <ameingast@gmail.com>
LicenseBSD-style
Maintainerameingast@gmail.com
Stabilityexperimental
PortabilityGHC
Safe HaskellNone
LanguageHaskell98

Network.Wai.Middleware.ETag

Description

WAI ETag middleware for static files.

Synopsis

Documentation

etag :: Bool -> MaxAge -> Middleware Source

Attaches the middleware. Enable caching if the first argument is True.

etag' :: ETagContext -> MaxAge -> Middleware Source

Attaches the middleware with a provided context.

respond :: Monad m => MaxAge -> Response -> [Header] -> m Response Source

Finalize the response by attaching a cache-control header based on age.

addCacheControl :: MaxAge -> Response -> Response Source

Add cache control headers to the response object.

modifiedSince :: Request -> Maybe HTTPDate Source

Determine if-modified-since tag from the http request if present.

hashFileCached :: ETagContext -> FilePath -> IO HashResult Source

Determine the hash of a provided file located at path. If caching is enabled, use the cached checksum, otherwise always re-calculate.

cacheControl :: MaxAge -> ResponseHeaders -> ResponseHeaders Source

Add cache-control to the provided response-headears.

hashFile :: FilePath -> IO HashResult Source

Hash the file with MD5 located at fp.

getModificationTimeIfExists :: FilePath -> IO (Maybe EpochTime) Source

Determine the file modification time at the location fp if it exists.

data MaxAge Source

Maximum age that will be attached to all file-resources processed by the middleware.

data HashResult Source

The result of an hash-calculation of a file.

data ETagContext Source

The configuration context of the middleware.

Constructors

ETagContext 

Fields

etagCtxUseCache :: !Bool

Set to false to disable the cache

etagCtxCache :: !(MVar (HashMap FilePath ByteString))

The underlying store mapping filepaths to calculated checksums

Instances