5

I have following code, it works fine in iOS7, but does not in iOS8.In iOS8, the app always use the cache even I have set NSURLRequestReloadIgnoringCacheData:

NSURL *url = [NSURL URLWithString:k_Chapter_URL];
NSMutableURLRequest* request = [[NSMutableURLRequest alloc] initWithURL:url];

NSURLSessionConfiguration *sessionConfig =
[NSURLSessionConfiguration defaultSessionConfiguration];
sessionConfig.requestCachePolicy = NSURLRequestReloadIgnoringCacheData;
NSURLSession *session = [NSURLSession sessionWithConfiguration:sessionConfig];

[[session dataTaskWithRequest:request
            completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {

            }] resume];

Is there anybody have similar situation with me?

modusCell
  • 13,151
  • 9
  • 53
  • 80
ikzjfr0
  • 767
  • 1
  • 7
  • 14

1 Answers1

1

I think this is a bug in iOS 8. I was able to use resetWithCompletionHandler to force the cache to clear.

[session resetWithCompletionHandler:^{
    [[session dataTaskWithRequest:request completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {

        }] resume];
}];
Eric Y
  • 1,677
  • 1
  • 12
  • 17