| Safe Haskell | Safe-Infered |
|---|
Network.Wai.Middleware.Cache
Contents
Description
Transparent front cache middleware for Wai.
Instead caching internal data, this middleware caches entire responses. Of course, this creates additional costs. However, the simplification of the internal structure and concentration of caching in the immediate vicinity of the request is more than redeem them.
cache (debugBackend True)
ourFrivolousApplication
- type CacheBackend = Application -> Request -> ResourceT IO (Maybe Response)
- data CacheBackendError = CacheBackendError ByteString
- cache :: CacheBackend -> Middleware
Backend
type CacheBackendSource
Abstract cache backend. Result may be Nothing you need to respond
wirh status 304 - Not Modified.
data CacheBackendError Source
Cache backend can throw errors. For handle this, use, for example, Network.Wai.Middleware.Catch.
Constructors
| CacheBackendError ByteString |
Middleware
Arguments
| :: CacheBackend | Cache backend. |
| -> Middleware |
Cache middleware. Use it with conjuction with CacheBackend.
-- Simplest backend. Suggests @304 - Not Modified@ with site root.
rootBackend app req = do
case rawPathInfo req of
"/" -> return Nothing
_ -> do
res <- app req
return $ Just res