I have an iOS application that fetches network resources by using URLRequest with default cachePolicy. I would like to know if:
Below is the behaviour of default Cache Policy explained by Apple:
Thanks.
The caches are stored in a file in your app’s container directory (specifically, Caches/BUNDLE_ID/Cache.db
in iOS, or Library/Caches/BUNDLE_ID/Cache.db
in macOS, IIRC). When the app goes away, so does the cache, and as far as I’m aware, they are never stored in iCloud backups or anything, so there should be no possibility of them resurfacing.
But be aware that other things can cache responses (e.g. proxy servers on the local network), so if your goal is to completely eliminate any possibility of getting a stale response, you should explicitly disable caching for the request.
If your goal is to have a prewarmed cache, you could distribute a cache file in your app bundle and make a copy of it on first launch before enabling the disk cache, but you are probably better off downloading a ZIP archive and managing files on disk yourself if you are trying to do any sort of offline mode, rather than trying to bend NSURLCache to your will.