views:

345

answers:

3

I am not sure, but I think I was reading a while ago that iPhone / iPod Touch don't cache anything to disk. They cache only in memory. So cache is not persistet when app quits. After relaunch of app it will re-fetch the data from the net. Is that true?

A: 

iPhone apps can write data to disk.

TechZen
+1  A: 

You can explore this yourself using the iPhone Simulator, opening a terminal or using the Finder, and going to `~Library/Application Support/iPhone Simulator/User/Applications/ then opening whatever directory your application is in.

You'll see a Documents directory, a Library and a tmp directory.

I've never looked to see if UIWebView is caching anything, but I know that Core Data will.

If you just suck down data yourself using CFNetwork, I believe it's up to you to cache the data yourself by saving it to tmp or Documents if you want.

tmp will not get backed up by the iTunes Sync process, but Documents will, so don't use Documents for temporary cache. Otherwise you'll just waste space and slow down sync backups.

The Documents directory will persist through anything, including app upgrades, except outright deleting the application using the Springboard or doing a total device storage wipe.

Actually the Library directory has directories. called Cache, WebKit/LocalStorage, and Preferences. So that would suggest something or the other.

Don't write to the application bundle directory or bad things could happen.

Nimrod
+1  A: 

iPhone OS disables on-disk caching from NSURLCache on this platform. If you need on-disk caching support anyway, you can use http://github.com/rs/SDURLCache which gives back on-disk cache support on iPhone OS

Olivier Poitrey