I'm trying to use a disk-based binding built into iOS 5. I have a json channel that I want to download and then cache, so that it loads instantly the next time the user uses the application. The cache.db file was created successfully, and if I open it in the sqlite editor, I can extract the data.
I am using AFNetworking
NSURL *url = [NSURL URLWithString:@"http://myurl.com/json"]; NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url]; NSLog(@"%d before call",[[NSURLCache sharedURLCache] currentDiskUsage]);
In the cache response block, strange, the cache now works and successfully receives a cache request from memory.
[operation setCacheResponseBlock:^NSCachedURLResponse *(NSURLConnection *connection, NSCachedURLResponse *cachedResponse) { NSCachedURLResponse *cachedResponse_ = [[NSURLCache sharedURLCache] cachedResponseForRequest:request]; NSLog(@"%d AFTER CACHE",[[NSURLCache sharedURLCache] currentDiskUsage]);
How can I load a cached url request from disk the next time the application starts?
source share