ResponseCacher

public struct ResponseCacher

ResponseCacher is a convenience CachedResponseHandler making it easy to cache, not cache, or modify a cached response.

  • Defines the behavior of the ResponseCacher type.

    • cache: Stores the cached response in the cache.
    • doNotCache: Prevents the cached response from being stored in the cache.
    • modify: Modifies the cached response before storing it in the cache.
    See more

    Declaration

    Swift

    public enum Behavior
  • Returns a ResponseCacher with a follow Behavior.

    Declaration

    Swift

    public static let cache: ResponseCacher
  • Returns a ResponseCacher with a do not follow Behavior.

    Declaration

    Swift

    public static let doNotCache: ResponseCacher
  • The Behavior of the ResponseCacher.

    Declaration

    Swift

    public let behavior: Behavior
  • Creates a ResponseCacher instance from the Behavior.

    Declaration

    Swift

    public init(behavior: Behavior)

    Parameters

    behavior

    The Behavior.

  • Declaration

    Swift

    public func dataTask(_ task: URLSessionDataTask,
                         willCacheResponse response: CachedURLResponse,
                         completion: @escaping (CachedURLResponse?) -> Void)