ASIHTTPRequest仅为一个URL清除缓存

时间:2012-07-24 13:33:48

标签: ios caching asihttprequest

我正在使用ASIHTTPRequest进行缓存,以便在我的iOS应用中下载图片。大多数图片永远不会改变,因此可以利用缓存功能。有一些根据iOS应用中的某个功能进行了更改。所以,我确切地知道这些图像何时会改变。如何清除某个链接的缓存(例如http://www.test.com/image.jpg)并为我的应用中的所有其他请求保留缓存。谢谢。

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];

1 个答案:

答案 0 :(得分:2)

[[ASIDownloadCache sharedCache] removeCachedDataForURL:[NSURL URLWithString:@"{Image url}"]];
相关问题