docs/Protocols/CachedResponseHandler.html
public protocol CachedResponseHandler : Sendable
A type that handles whether the data task should store the HTTP response in the cache.
`
dataTask(_:willCacheResponse:completion:)
`
Determines whether the HTTP response should be stored in the cache.
The completion closure should be passed one of three possible options:
nil value to prevent the cached response from being stored in the cache.Swift
func dataTask(_ task: URLSessionDataTask,
willCacheResponse response: CachedURLResponse,
completion: @escaping (CachedURLResponse?) -> Void)
| task |
The data task whose request resulted in the cached response.
|
| response |
The cached response to potentially store in the cache.
|
| completion |
The closure to execute containing cached response, a modified response, or nil.
|
Self == ResponseCacher`
cache
` Extension method
Provides a ResponseCacher which caches the response, if allowed. Equivalent to ResponseCacher.cache.
Swift
public static var cache: ResponseCacher { get }
`
doNotCache
` Extension method
Provides a ResponseCacher which does not cache the response. Equivalent to ResponseCacher.doNotCache.
Swift
public static var doNotCache: ResponseCacher { get }
`
modify(using:)
` Extension method
Creates a ResponseCacher which modifies the proposed CachedURLResponse using the provided closure.
Swift
public static func modify(using closure: @escaping (@Sendable (URLSessionDataTask, CachedURLResponse) -> CachedURLResponse?)) -> ResponseCacher
| closure |
Closure used to modify the CachedURLResponse.
|
The ResponseCacher.