Multiple middlewares can be chained together with normal function composition, e.g.:
middleware1 . middleware2
So if you had a middleware that added the cache settings to the response, you should be set. A basic structure that may help you is:
addCacheSettings :: Middleware
addCacheSettings innerApp request = do
innerResponse <- innerApp request
return $ myHelper innerResponse
where
myHelper :: Response -> Response
myHelper = error "Your logic here"