2012-07-24 41 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}"]];