Prevent caching of redirect

Dynamic redirects shouldn't be cached.  This especially causes a problem
with redirection to the login page, since trying to actually access the
page the user logged in to see can get them redirected back to the login
page on some browsers.

This patch adds headers to prevent caching of all redirects, which isn't
ideal, but better than allowing caching of all of them.
This commit is contained in:
David L. L. Thomas 2012-11-21 22:39:53 -08:00
parent d37b0634a5
commit a2ad8fe704

View File

@ -522,7 +522,11 @@ runHandler handler mrender sroute tomr master sub upload log' =
Right c' -> return $ YARPlain status (appEndo headers []) ct c' finalSession
HCError e -> handleError e
HCRedirect status loc -> do
let hs = Header "Location" (encodeUtf8 loc) : appEndo headers []
let hs =
[ Header "Cache-Control" "no-cache, must-revalidate"
, Header "Expires" "Thu, 01 Jan 1970 05:05:05 GMT"
, Header "Location" (encodeUtf8 loc)
] ++ appEndo headers []
return $ YARPlain
status hs typePlain emptyContent
finalSession