I’m making some network calls in my iPhone app, and I’ve noticed that they’re behaving as if the response is being cached. For example, if I press a button to download something that is nontrivial in size (and thus will result in a perceptive delay when downloading), it behaves as expected the first time and takes a second or two. If I repeat the process, it finishes pretty much instantly. I’ve also updated some of the files it depends on server-side and refreshed from the app, and the changes don’t appear.
My networking code is pretty simple, and isn’t doing anything with caching. It’s essentially a convenience wrapper around [NSURLConnection sendAsynchronousRequest:... along with some logging and logic to make sure the system network activity indicator is showing when requests are outstanding. See here for complete details (GitHub link).
Is my guess of caching a valid guess for this behavior? If so, could it be happening on the device, and can I disable it? I want my data to actually refresh when I want it to.
Are you setting the cache policy on your
NSURLRequest?Take a look at the NSURLRequest Docs and look at the
NSURLRequestCachePolicysection for different caching policies you can use.