Below given code works in iOS 6 but it does not work on iOS 7.
NSCachedURLResponse cachedURLResponse = [[NSCachedURLResponse alloc] initWithResponse:response data:data userInfo:nil storagePolicy:NSURLCacheStorageAllowed];
[[NSURLCache sharedURLCache] storeCachedResponse:cachedURLResponse forRequest:request];
NSLog(@"Cached response is %@", [[NSURLCache sharedURLCache] cachedResponseForRequest:request]);
In iOS 6 I am getting the cached response data but in iOS 7 it returns null. I have set the NSURLCache object in App delegate using:
NSURLCache *urlCache = [[NSURLCache alloc] initWithMemoryCapacity:2 * 1024 * 1024
diskCapacity:2 * 1024 * 1024
diskPath:nil];
[NSURLCache setSharedURLCache:urlCache];
What is the reason of caching not working in iOS 7?