Persisting image data in NSDocumentDirectory - limit?


#1

Hey everyone,

This is my first post and I’d like to start out by thanking Joe, Aaron and the rest of the folks at BNR for the great book. I’ve recently finished the book in anticipation for my new iOS project and I had a question about cache.

Part of the app requires showing images that will change semi-regularly; however, I’d like to cache these images locally to avoid needing to make constant network requests when the app loads. I’ve implemented my own loading manager (which is probably a bad idea for production value, but I’m mainly learning still) and it caches image data in-session so I don’t make multiple network requests for the same file, but I want to implement a caching strategy that stores the images on the client device too.

From what I remember in the book, there are two ways to handle caching locally: archiving and core data. The simplicity of the image storage lends me to feel archiving is a better solution and I’ve implemented it successfully in my app, but now that I start thinking about it, the number of cached images (specifically the images cached to disk) can grow to a large amount and I’ll need a way to prune old ones or something.

My main question is what are the best practices for the amount of storage an app should take on the device? I can implement pruning/limits easily, but I’m not sure what are the best practices for this.

Thoughts?

Thanks guys,
Chris