2012-07-24 42 views
0

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

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

回答

2
[[ASIDownloadCache sharedCache] removeCachedDataForURL:[NSURL URLWithString:@"{Image url}"]];