How does an iOS app use Cache.db ?

Hello All,


I want to know, how does NSURLSession / NSMutableURLRequest API uses Cache.db file created in app sandbox ~/Library/Caches/iOS-app-bundle-identifier/Cache.db file.


What will happen if I programmatically delete that file when user logs out of my app ? will it affect the performance of the app the next time user logs back in my app ?

Accepted Answer

What will happen if I programmatically delete that file when user logs out of my app ?

You must not monkey with the

Cache.db
. The presence and format of that file is not considered API. Moreover, there have been cases in the past where folks deleting the file out from underneath NSURLSession have caused it to crash.

If you want to programmatically manipulate the NSURLCache, use the NSURLCache API. Specifically, it sounds like

-removeAllCachedResponses
would be of interest to you.

will it affect the performance of the app the next time user logs back in my app ?

That really depends on how effectively your app is using the NSURLCache.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"
How does an iOS app use Cache.db ?
 
 
Q