Reputation: 8449
I tried to clear cache bit the size of the app does not become significantly smaller.
My app size is about 30MB plus 45MB for cached images.
This is how I attempted to clear cache:
[[NSURLCache sharedURLCache] removeAllCachedResponses];
[[AFImageDownloader defaultURLCache] removeAllCachedResponses];
AFAutoPurgingImageCache *imageCache = [AFImageDownloader defaultInstance].imageCache;
[imageCache removeAllImages];
com.alamofire.imagedownloader/fsCachedData
all the files are still thereThis is how I download images using AFNetworking (3.1.0):
#import "AFImageDownloader.h"
[photoImageView setImageWithURLRequest:[NSURLRequest requestWithURL:thumb] placeholderImage:myCachedImage success:^(NSURLRequest *request, NSHTTPURLResponse *response, UIImage *image) {
[self setPhotoImage:image];
} failure:^(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error) {
[self setupPlaceholder];
}];
Upvotes: 4
Views: 751
Reputation: 125
This code works for AFNetworking 3.1:
[[NSURLCache sharedURLCache] removeAllCachedResponses];
AFImageDownloader *imageDownloader = [AFImageDownloader defaultInstance];
NSURLCache *urlCache = imageDownloader.sessionManager.session.configuration.URLCache;
[urlCache removeAllCachedResponses];
[imageDownloader.imageCache removeAllImages];
Upvotes: 0
Reputation: 4815
We are seeing this in one of our apps as well. According to this http://blog.airsource.co.uk/2014/10/11/nsurlcache-ios8-broken/, its an iOS 8 bug which Apple will have corrected in the iOS 8.1 update today.
So to answer your question: No, you shouldn't have to delete the cache yourself and with some luck Apple's fix really will clean up the old data. If for some reason not, you should be able to delete it yourself without any problems.
I've verified that iOS 8.1 does indeed correct the issue. The user must launch the app once after update for the cache to be cleared however.
Upvotes: 1
Reputation: 1253
See follows:
AFAutoPurgingImageCache *imageCache = [AFImageDownloader defaultInstance].imageCache;
The imageCache
is stored in the memory, it is useless to do [imageCache removeAllImages];
[[AFImageDownloader defaultURLCache] removeAllCachedResponses];
. It is the only API that apple offers to clear the URLCache
.fsCachedData
is not removed when you call removeAllCachedResponses
. It is because apple has its own mechanism to clear the disk data. Maybe it will clear the disk data in every 7 days as i searched, but i can not make sure.fsCachedData
. Should I clear the fsCachedData folder myself?Upvotes: 2