Skip to content
Merged
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
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
## [_Unreleased_](https://github.com/freckle/freckle-http/compare/v0.3.0.1...main)
## [_Unreleased_](https://github.com/freckle/freckle-http/compare/v0.3.1.0...main)

## [v0.3.1.0](https://github.com/freckle/freckle-http/compare/v0.3.0.1...v0.3.1.0)

- Add `HttpCacheSettings{forceTTL}`

## [v0.3.0.1](https://github.com/freckle/freckle-http/tree/v0.3.0.1)

Expand Down
2 changes: 1 addition & 1 deletion freckle-http.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ cabal-version: 1.18
-- see: https://github.com/sol/hpack

name: freckle-http
version: 0.3.0.1
version: 0.3.1.0
synopsis: Toolkit for making HTTP requests
description: Please see README.md
category: HTTP
Expand Down
5 changes: 4 additions & 1 deletion library/Freckle/App/Http/Cache.hs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ import Text.Read (readMaybe)
data HttpCacheSettings m t = HttpCacheSettings
{ shared :: Bool
, cacheable :: Request -> Bool
, forceTTL :: Maybe CacheTTL
, defaultTTL :: CacheTTL
, getCurrentTime :: m UTCTime
, logDebug :: Message -> m ()
Expand Down Expand Up @@ -238,7 +239,9 @@ getCachableResponseTTL settings resp = do
guard
$ not settings.shared || Private `notElem` responseHeaders.cacheControl
guard $ statusIsCacheable $ HTTP.responseStatus resp
pure $ fromMaybe settings.defaultTTL $ responseHeadersToTTL responseHeaders
pure $ case settings.forceTTL of
Nothing -> fromMaybe settings.defaultTTL $ responseHeadersToTTL responseHeaders
Just ttl -> ttl
where
responseHeaders = getResponseHeaders resp

Expand Down
1 change: 1 addition & 0 deletions library/Freckle/App/Http/Cache/Memcached.hs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ memcachedHttpCacheSettings defaultTTL =
HttpCacheSettings
{ shared = True
, cacheable = const True
, forceTTL = Nothing
, defaultTTL
, getCurrentTime = liftIO getCurrentTime
, logDebug = logDebugNS "http.cache"
Expand Down
1 change: 1 addition & 0 deletions library/Freckle/App/Http/Cache/State.hs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ stateHttpCacheSettings =
HttpCacheSettings
{ shared = False
, cacheable = const True
, forceTTL = Nothing
, defaultTTL = fiveMinuteTTL
, getCurrentTime = liftIO getCurrentTime
, logDebug = \_ -> pure ()
Expand Down
2 changes: 1 addition & 1 deletion package.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: freckle-http
version: 0.3.0.1
version: 0.3.1.0
maintainer: Freckle Education
category: HTTP
github: freckle/freckle-http
Expand Down
Loading