From 246a024dce1db84060a0efe518addc8ef3dc9097 Mon Sep 17 00:00:00 2001 From: "David L. L. Thomas" Date: Fri, 23 Nov 2012 13:44:31 -0800 Subject: [PATCH] Allowing cache on 301 redirects --- yesod-core/Yesod/Handler.hs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/yesod-core/Yesod/Handler.hs b/yesod-core/Yesod/Handler.hs index 226c10a4..651ac200 100644 --- a/yesod-core/Yesod/Handler.hs +++ b/yesod-core/Yesod/Handler.hs @@ -522,11 +522,12 @@ 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 = + let disable_caching = [ Header "Cache-Control" "no-cache, must-revalidate" , Header "Expires" "Thu, 01 Jan 1970 05:05:05 GMT" - , Header "Location" (encodeUtf8 loc) - ] ++ appEndo headers [] + ] + hs = (if status == H.movedPermanently301 then disable_caching else []) + ++ Header "Location" (encodeUtf8 loc) : appEndo headers [] return $ YARPlain status hs typePlain emptyContent finalSession