Reputation: 1537
I have been having an issue where no matter what framework i use to cache my images, from AFNetworking to SDWebImage's caching techniuqes to write to the disk. Everytime i press the home button, then go back to the app. Its like all the images have to be RE cached.
I have no clue where to start looking
In order to use both AFNetworking for my regular networking functions, such as JSON and image uploading i used https://gist.github.com/sibljon/5957892 to resolve namespace collisions so i cold totally override AFNetworkings UIImageView and stick with SDWebImage so instead of calling
Thanks to jonsibley and his answer i dont call
[imageFile setImageWithURL:[NSURL URLWithString:friendAvatar] placeholderImage:[UIImage imageNamed:@"defaultProfileImage.png"]];
im now calling (just a SD_ in front now) which allows me to override AFNetworkings caching. Correct?
[imageFile SD_setImageWithURL:[NSURL URLWithString:friendAvatar] placeholderImage:[UIImage imageNamed:@"defaultProfileImage.png"]];
EDIT UDPATE:
After much more testing i found out that the app is cleaning the cache once it RESUMES the app, NOT when it starts to get suspended (when home button is pressed) Any clue to what may be causing this?
Upvotes: 0
Views: 1268
Reputation: 66252
Here are two possibilities. Please note the difference between clea r Disk and clea n Disk.
SDWebImage calls cleanDisk
upon receiving a UIApplicationWillTerminateNotification
. This method removes files that are older than their expiration date. After that, it clears files from oldest to newest until the configured maximum cache size is reached.
If you aren't setting your SDImageCache's maxCacheSize
property, this property is ignored.
If you aren't setting your SDImageCache's maxCacheAge
property, it defaults to 604800
seconds (1 week).
Do you have any calls to SDWebImage's clearDisk
or clearMemory
methods in your app? If so, set breakpoints on them to find why they're called during resume.
[SDImageCache -cleanDisk]
and step through it to see why your cache is getting cleared.Upvotes: 3