A cached response to a URL request.


An CachedURLResponse object provides the server’s response metadata in the form of an URLResponse object, along with an NSData object containing the actual cached content data. Its storage policy determines whether the response should be cached on disk, in memory, or not at all.

Cached responses also contain a user info dictionary where you can store app-specific information about the cached item.

The URLCache class stores and retrieves instances of CachedURLResponse.


Creating a cached URL response

Getting cached URL response properties

var data: Data

The receiver’s cached data.

var response: URLResponse

The URL response object associated with the receiver.

var storagePolicy: URLCache.StoragePolicy

The receiver’s cache storage policy.

var userInfo: [AnyHashable : Any]?

The receiver’s user info dictionary.


enum URLCache.StoragePolicy

These constants specify the caching strategy used by an NSCachedURLResponse object.


Inherits From

See Also

Cache Behavior

Accessing Cached Data

Control how URL requests make use of previously cached data.

class URLCache

An object that maps URL requests to cached response objects.