1

Even after setting the Cache Policy, my NSURLSession is still loading cached data:

let url = NSURL(string: urlString);
var sessionConfig = NSURLSessionConfiguration.defaultSessionConfiguration();
sessionConfig.requestCachePolicy = NSURLRequestCachePolicy.ReloadIgnoringLocalAndRemoteCacheData;
var session = NSURLSession(configuration: sessionConfig);

Is there a reason why the session is ignoring the .ReloadIgnoringLocalAndRemoteCacheData?

Jake Chasan
  • 6,290
  • 9
  • 44
  • 90
  • How are you checking that the session is "ignoring" the cache policy? – Mundi Jun 13 '15 at 15:18
  • @Mundi: I am printing out the data that is returned by the session.dataTaskWithURL(url!) {(data, response, error). I then change the file on the server, and the printout in the console is still the same. – Jake Chasan Jun 13 '15 at 15:19

1 Answers1

2

From NSURLRequest Class Reference page

NSURLRequestReloadIgnoringLocalAndRemoteCacheData = 4, // Unimplemented
NSURLRequestReloadRevalidatingCacheData = 5 // Unimplemented 

I guess, the constant is there but should not be used.

Yaroslav
  • 2,435
  • 1
  • 19
  • 36