I'm looking for a network caching solution for my iOS application that is persistent across launches. I started to read about NSURLCache, but didn't see any mention regarding persistence. Does anyone know how this behaves when you use NSURLCache then close and open the app? Does it persist?
NSURLCache
automatically caches requests for requests made overNSURLConnection
andUIWebView
s according to the cache response from the server, the cache configuration, and the request's cache policy. These responses are stored in memory and on disk for the lifetime of the cache.Aside
I validated the behavior with the following code. You do not need to use any of the below in your own code. This is just to demonstrate how I confirmed the behavior.
The code does the following:
On first load, you should see "No cached response found." On subsequent runs, you will see "Cached response found!"