dgee4
dgee4

Reputation: 381

Xcode iOS Image Caching

I am fetching images from my server and need to store them on the disk. I was wondering what is the best way to cache these images to prevent excessive requests and traffic. From doing some research it seems that there are many options available but I am not sure which to use.

  1. Core Data
  2. Store in the Cache Resources Folder in the file directory

After storing these is it best to use a NSCache class to put these data into memory for quick access or is Core Data quick enough?

Upvotes: 0

Views: 1881

Answers (2)

NSWill
NSWill

Reputation: 659

I've had great results using FastImageCache by Path.

What Fast Image Cache Does

  • Stores images of similar sizes and styles together
  • Persists image data to disk
  • Returns images to the user significantly faster than traditional methods
  • Automatically manages cache expiry based on recency of usage
  • Utilizes a model-based approach for storing and retrieving images
  • Allows images to be processed on a per-model basis before being stored into the cache

Upvotes: 0

Ges83
Ges83

Reputation: 82

Based on my experience, you could use SDWebImage, which caches the images you request based on their url, so the next time you "request" it, it will check if it is in cache, if so it won't make the request and it will load it from it instead.

I'm not sure why would you need to store the image, maybe you could tell us the reason and see if we can help any further.

Upvotes: 2

Related Questions