大佬教程收集整理的这篇文章主要介绍了ios – NSURLCache cachedResponseForRequest不检索缓存数据,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
NSString *theCompleteURL = @"http://192.168.1.2:8080/api/endpoint.json"; NSURLrequest *request = [NSURLrequest requestWithURL:[NSURL URLWithString:theCompleteURL]]; NSCachedURLResponse *response = [[NSURLCache sharedURLCache] cachedResponseForrequest:request]; if (responsE) { NSLog(@"Cached data found"); } else { NSLog(@"Cached data not found"); }
但我总是从方法cachedResponseForrequest的“响应”变量的响应中得到nil.
我确信数据是在缓存中,因为我在我的应用程序的Cache.db文件中检查了它,从cfurl_cache_response表获取此结果:
sqlite> SELEct * from cfurl_cache_response; 1|0|1875686237|0|http://192.168.1.2:8080/api/endpoint.json|2014-01-09 11:55:17| sqlite>
在ApplicationDelegate中,NSURLCache配置为:
NSURLCache *cache = [[NSURLCache alloc] initWithMemoryCapacity:5 * 1024 * 1024 diskCapacity:40 * 1024 * 1024 diskPath:nil]; [NSURLCache setSharedURLCache:cache];
关于缓存可能发生什么的任何想法?
我的端点的标题看起来像:
$curl -I http://192.168.1.2:8080/api/endpoint.json http/1.1 200 OK Content-Length: 1385 Expires: Thu,01 Dec 2020 16 00: 00 GMT Content-Type: application/json;charset=utf-8 ETag: "3e86-410-3596fbbc" Cache-Control: max-age=3600 Connection: keep-alive Server: thin 1.5.1 codename STraight Razor $
以上是大佬教程为你收集整理的ios – NSURLCache cachedResponseForRequest不检索缓存数据全部内容,希望文章能够帮你解决ios – NSURLCache cachedResponseForRequest不检索缓存数据所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。