首页 > 关于afnetworking nsurlcache做缓存,求指教

关于afnetworking nsurlcache做缓存,求指教

[manager POST:urlString parameters:dic success:^(AFHTTPRequestOperation *operation, id responseObject) {

    NSLog(@"%@",operation);
    NSLog(@"%@",responseObject);

NSCachedURLResponse *re=[[NSCachedURLResponse alloc] initWithResponse:operation.response data:operation.responseData userInfo:nil storagePolicy:NSURLCacheStorageAllowed];

    [[CustomURLCache sharedURLCache] storeCachedResponse:re forRequest:operation.request];

    NSCachedURLResponse* cachedResponse = [[CustomURLCache sharedURLCache] cachedResponseForRequest:operation.request];

我想用这种方法做缓存 NSCachedURLResponse* cachedResponse 这样取出来一直是nil,但在沙盒看了,确实存了,请问问题出在哪里了


我找了整整三天答案,至今没有弄清楚原因。我的问题和你一样,我做了各种试验来验证我的想法,但是我依然不明白原因。我查看了数据库,保存的缓存确实把json入参一并记录到了request_key里,可是你用代码取的时候不能带httpbody,即使是同一个request对象,也取不出来刚果存进去的cache,非常搞不懂!!但是你把那个request的httpbody制空,就可以取到了。换句话说,缓存不支持区分json入参!!??

【热门文章】
【热门文章】