Reputation: 2660
I'm using ASIHTTPRequest with caching for downloading pictures in my iOS app. Most pictures never change and hence can leverage the caching functionality. There are a few that do change based on a certain function in the iOS app. So, I know exactly when these images will change. How can I clear the cache of a certain link (e.g. http://www.test.com/image.jpg) and preserve the cache for all other requests in my app. Thanks.
ASIHTTPRequest *request;
request = [ASIHTTPRequest requestWithURL:[NSURL URLWithString:@"{Image url}"]];
[request setDownloadCache:[ASIDownloadCache sharedCache]];
[request setCachePolicy:ASIAskServerIfModifiedWhenStaleCachePolicy|ASIFallbackToCacheIfLoadFailsCachePolicy];
[request setCacheStoragePolicy:ASICachePermanentlyCacheStoragePolicy];
[request setSecondsToCache:60*60*24*7];
Upvotes: 0
Views: 916
Reputation: 14677
[[ASIDownloadCache sharedCache] removeCachedDataForURL:[NSURL URLWithString:@"{Image url}"]];
Upvotes: 2