我像这样创建url,它是在后台线程中调用的函数的一部分。
NSURL *url = [NSURL URLWithString:urlString];
NSData *pageData = [NSData dataWithContentsOfURL:url];当我尝试缓存它的时候
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.
NSURLCache *URLCache = [[NSURLCache alloc] initWithMemoryCapacity:4 * 1024 * 1024
diskCapacity:20 * 1024 * 1024
diskPath:nil];
[NSURLCache setSharedURLCache:URLCache];
}然而,如果我打开应用程序,关闭它,并尝试再次打开它,应用程序需要同样的时间来加载,并且速度没有明显的提高。我想知道缓存是否有iOS限制,或者我是否错误地实现了代码。
发布于 2014-08-05 06:16:26
您的申请中是否包含适当的电子标签?您的服务器返回的是200还是304?
为了知道缓存的数据是否可以使用,服务器需要指出它没有更改。
https://stackoverflow.com/questions/25128395
复制相似问题