Search code examples
iosnsurlcache

On iOS where is the NSURLCache cache stored if diskPath:nil?


I've come across code that looks like this:

NSURLCache *URLCache = 
    [[NSURLCache alloc] initWithMemoryCapacity:1024 * 1024 
                                  diskCapacity:1024 * 1024 * 5 
                                      diskPath:nil];

The problem is that I haven't been able to find what's the expected behavior when diskPath is passed nil. NSURLCache docs don't explicitly describe this situation nor I have been able to figure it out with my own testing.

Where is the cache stored? or is that code above a bug?

Thanks.


Solution

  • I had some free time today to do some testing and found the answer. Nothing exciting but if you are curious:

    By default iOS will use a database named Cache.db and, as @qegal mentioned, will be stored under the default location.