Search code examples
ioscachingafnetworkingios12nsurlcache

How to use cache policy NSURLRequestReloadRevalidatingCacheData


The links below

iOS - Download file only if modified (NSURL & NSData)

http://nshipster.com/nsurlcache/

mentions that NSURLRequestReloadRevalidatingCacheData is not yet implemented in iOS 7.

Is this implemented in iOS 12? If it is, can you tell me how to use it?

If not, what are the alternatives / best practices for validating cache against server before using?

Thanks!


Solution

  • NSURLRequestReloadRevalidatingCacheData (ReloadRevalidatingCacheData in Swift) is still not implemented in iOS9.

    You can implement this behaviour manually by sending a HEAD network request and checking last modification date. Here's how to do it: iOS - Download file only if modified (NSURL & NSData)