Alamofire loading from cache even when cache policy set to ReloadIgnoringLocalAndRemoteCacheData
I'm using this way in a project and it's working:
let mutableURLRequest = NSMutableURLRequest(URL: SERVICEURL)
mutableURLRequest.HTTPMethod = "POST"
mutableURLRequest.HTTPBody = self.createJson()
mutableURLRequest.setValue("application/json", forHTTPHeaderField: "Content-Type")
mutableURLRequest.cachePolicy = NSURLRequestCachePolicy.ReloadIgnoringCacheData
request(mutableURLRequest).validate().responseJSON{ response in...
Hope it helps.
Thanks to @FábioSalata I solved my problem like this.
var req = URLRequest(url: URL(string: "<URL>")!)
req.httpMethod = "GET"
req.setValue("application/json", forHTTPHeaderField: "Content-Type")
req.setValue("<Auth KEY>", forHTTPHeaderField:"Authorization" )
req.cachePolicy = NSURLRequest.CachePolicy.reloadIgnoringCacheData
Alamofire.request(req).validate().responseJSON { response in ...
ReloadIgnoringLocalAndRemoteCacheData is not implemented.
https://developer.apple.com/reference/foundation/nsurlrequestcachepolicy/1408722-reloadignoringlocalandremotecach
http://nshipster.com/nsurlcache/
Update: Starting with iOS 13, NSURLRequest.CachePolicy.reloadRevalidatingCacheData and NSURLRequest.CachePolicy.reloadIgnoringLocalAndRemoteCacheData are implemented. https://developer.apple.com/documentation/ios_ipados_release_notes/ios_13_release_notes