URLCache class implements the caching of responses to URL load requests by mapping
NSURLRequest objects to
NSCachedURLResponse objects. It provides a composite in-memory and on-disk cache, and lets you manipulate the sizes of both the in-memory and on-disk portions. You can also control the path where cache data is stored persistently.
- iOS 8.0+
- macOS 10.10+
- tvOS 9.0+
- watchOS 2.0+
In iOS 8 and later, and macOS 10.10 and later,
URLCache is thread safe.
URLCache instance methods can safely be called from multiple execution contexts at the same time, be aware that methods like
storeCachedResponse(_:for:) have an unavoidable race condition when attempting to read or write responses for the same request.
URLCache must implement overridden methods in such a thread safe manner.