if (self) {
// Custom initialization
//初始化ASIDownloadCache缓存对象
ASIDownloadCache *cache = [[ASIDownloadCache
alloc] init];
self.downloadCache = cache;
[cache release];
//路径
NSArray *paths =
NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask,
YES);
NSString *documentDirectory = [paths
objectAtIndex:0];
//设置缓存存放路径
[self.downloadCache
setStoragePath:[documentDirectory stringByAppendingPathComponent:@"resource"]];
// [self.downloadCache setDefaultCachePolicy:ASIAskServerIfModifiedWhenStaleCachePolicy];
[[ASIDownloadCache
sharedCache]setShouldRespectCacheControlHeaders:NO];
NSURL *url = [NSURL
URLWithString:CMBURLString(kCityListAPI)];
ASIHTTPRequest *request = [ASIHTTPRequest
requestWithURL:url];
[request setCacheStoragePolicy:ASICachePermanentlyCacheStoragePolicy ];
[request setDownloadCache:downloadCache];
[request setSecondsToCache:60*60*24*7];
//缓存7天
[request setDelegate:self];
[request startAsynchronous];
}