What is the default diskspace that URLCache.shared instance has

Viewed 1466

Is it necessary to assign diskspace when I use URLCache.share instance? What is the default value that it has?

3 Answers

@ScottZhu's answer in Swift:

URLCache.shared.memoryCapacity
URLCache.shared.diskCapacity
URLCache.shared.currentMemoryUsage
URLCache.shared.currentDiskUsage

Here's your default cache size in bytes:

po URLSession.shared.configuration.urlCache?.currentMemoryUsage
- some : 1859

po URLSession.shared.configuration.urlCache?.memoryCapacity
- some : 512000

po URLSession.shared.configuration.urlCache?.diskCapacity
- some : 10000000

po URLSession.shared.configuration.urlCache?.currentDiskUsage
- some : 98408

Different devices might have different cache sizes, but that's the way to check it.

Related