3

I have a JSON file on S3 I'm downloading over HTTP with an NSURLConnection. I set the connection to use a caching policy of NSURLCacheStorageNotAllowed but I was still seeing an old version of the data come back. I changed to NSURLRequestReloadIgnoringLocalAndRemoteCacheData and the caching behaviour works.

Can anyone explain why?

Rog
  • 17,070
  • 9
  • 50
  • 73

2 Answers2

2

This is a mistake by not understanding the difference between NSURLCachedStoragePolicy and NSURLRequestCachePolicy, please see my answer here:

https://stackoverflow.com/a/24783824/1800915

Community
  • 1
  • 1
Wladek Surala
  • 2,590
  • 1
  • 26
  • 31
1

As of today, it looks like NSURLRequestReloadIgnoringLocalAndRemoteCacheData is actually doing nothing. From NSURLRequest.h in OS 10.9.1:

Screenshot of NSURLRequest.h

It looks like the best bet may be to use NSURLRequestReloadIgnoringLocalCacheData instead. (Unless Apple simply forgot to update its header file to remove that comment.)

Bryan
  • 4,628
  • 3
  • 36
  • 62