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

PortabilityGHC
Stabilityexperimental
Maintainerameingast@gmail.com
Safe HaskellNone

Network.Wai.Middleware.ETag

Description

WAI ETag middleware for static files.

Synopsis

Documentation

etag :: Bool -> MaxAge -> MiddlewareSource

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

etag' :: ETagContext -> MaxAge -> MiddlewareSource

Attaches the middleware with a provided context.

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

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

addCacheControl :: MaxAge -> Response -> ResponseSource

Add cache control headers to the response object.

modifiedSince :: Request -> Maybe HTTPDateSource

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

hashFileCached :: ETagContext -> FilePath -> IO HashResultSource

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 -> ResponseHeadersSource

Add cache-control to the provided response-headears.

hashFile :: FilePath -> IO HashResultSource

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