I solved a similar problem in the application that I am developing. There are thousands of users in my application, and everyone can have an avatar.
To improve performance, I developed a level 3 controller to manage avatar request.
First I check for NSCache (all the most recent avatars I use are stored in NSCache, which is handled by iOS, so I donโt have to worry about releasing cache if necessary). You just need to define a few parameters to configure NSCache.
If an avatar is not found in NSCache, I check my local Db (Sqlite), where the most recently used avatars are saved as Blob fields. Just remember that sometimes you need to perform a cleanup on a local Db, letting go of the old data to save the deviceโs memory.
If still not found, I save the request in the queue using the LIFO method (the latter in the first case). This means that whenever a local user scrolls the list of users, the current user avatars on the screen should be received before those that were already outside the table view screen.
Once again, in order to increase productivity again (decide it of your choice), while the user scrolls the screen quickly, I do not request any download. I just start asking for downloads when the user slows down the table scrolling. In addition, I limit the number of concurrent downloads. A new download starts only when the download slot is opened (upon successful completion or failure).
These optimizations work very well for me, my application works light.
I hope this can help you.
Jorg b jorge
source share