From a2ad8fe704f09e364c0bbfc8a7ebfc941810e994 Mon Sep 17 00:00:00 2001 From: "David L. L. Thomas" Date: Wed, 21 Nov 2012 22:39:53 -0800 Subject: [PATCH] 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. --- yesod-core/Yesod/Handler.hs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/yesod-core/Yesod/Handler.hs b/yesod-core/Yesod/Handler.hs index 493d7f0d..226c10a4 100644 --- a/yesod-core/Yesod/Handler.hs +++ b/yesod-core/Yesod/Handler.hs @@ -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