public protocol CachedResponseHandler
A type that handles whether the data task should store the HTTP response in the cache.
Determines whether the HTTP response should be stored in the cache.
completionclosure should be passed one of three possible options:
- The cached response provided by the server (this is the most common use case).
- A modified version of the cached response (you may want to modify it in some way before caching).
nilvalue to prevent the cached response from being stored in the cache.
func dataTask(_ task: URLSessionDataTask, willCacheResponse response: CachedURLResponse, completion: @escaping (CachedURLResponse?) -> Void)
The data task whose request resulted in the cached response.
The cached response to potentially store in the cache.
The closure to execute containing cached response, a modified response, or
ResponseCacherwhich modifies the proposed
CachedURLResponseusing the provided closure.
public static func modify(using closure: @escaping ((URLSessionDataTask, CachedURLResponse) -> CachedURLResponse?)) -> ResponseCacher
Closure used to modify the