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
  • 16,650
  • 9
  • 48
  • 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,392
  • 1
  • 23
  • 30
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
  • 3,838
  • 2
  • 26
  • 49