Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions yesod-core/ChangeLog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# ChangeLog for yesod-core

## Unreleased

* Fix documentation around `Expires` header [#1909](https://github.com/yesodweb/yesod/pull/1909)

## 1.6.29.1

* Fix compilation error for text >= 2.1.2 [#1905](https://github.com/yesodweb/yesod/pull/1905)
Expand Down
4 changes: 2 additions & 2 deletions yesod-core/src/Yesod/Core/Handler.hs
Original file line number Diff line number Diff line change
Expand Up @@ -889,8 +889,8 @@ cacheSeconds i = setHeader "Cache-Control" $ T.concat
, ", public"
]

-- | Set the Expires header to some date in 2037. In other words, this content
-- is never (realistically) expired.
-- | Set the Expires header to a date one year from now. In other words, this
-- content is never (realistically) expired.
neverExpires :: MonadHandler m => m ()
neverExpires = do
setHeader "Expires" . rheMaxExpires =<< askHandlerEnv
Expand Down
2 changes: 1 addition & 1 deletion yesod-core/src/Yesod/Core/Internal/Util.hs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ formatRFC822 :: UTCTime -> T.Text
formatRFC822 = T.pack . formatTime defaultTimeLocale "%a, %d %b %Y %H:%M:%S %z"

{- | Get the time 365 days from now in RFC 1123 format. For use as an expiry
date on a resource that never expires. See RFC 2616 section 14.21 for details.
date on a resource that never expires. See RFC 9111 section 5.3 for details.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

RFC 2616 has been obsoleted by RFC 7234, which in turn has been obsoleted by RFC 9111.

Side note:
Initially, the expiry date was set to the year 2037. This was changed in #870.

The newer standard theoretically permits longer lifetimes but I think it doesn't hurt to keep the current behaviour. The relevant passage:

Historically, HTTP required the Expires field value to be no more than a year in the future. While longer freshness lifetimes are no longer prohibited, extremely large values have been demonstrated to cause problems (e.g., clock overflows due to use of 32-bit integers for time values), and many caches will evict a response far sooner than that.

-}
getCurrentMaxExpiresRFC1123 :: IO T.Text
getCurrentMaxExpiresRFC1123 = fmap (formatRFC1123 . addUTCTime (60*60*24*365)) getCurrentTime
Loading