1
我有一个用例,我需要在Apple TV上轮询一个休息api以进行身份验证。我得到陈旧的响应JSON响应90-120秒之后,我得到适当的JSON响应。 下面是我的代码NSURLRequest with cachePolicy ReloadIgnoringCacheData返回陈旧数据
static func getFileNoCache(url:NSURL?, completionHandler:(NSData?, String?)->Void) {
if let fileUrl = url {
let request = NSURLRequest(URL: fileUrl, cachePolicy: .ReloadIgnoringCacheData, timeoutInterval: 5)
let dataTask = NSURLSession.sharedSession().dataTaskWithRequest(request,
completionHandler: { data, response, error in
if let err = error {
// failed !
print("!! Error - Download Failed \n\t\(fileUrl) reason:\(err.localizedDescription)")
completionHandler (nil, err.localizedDescription)
return
}
if let statusCode = (response as? NSHTTPURLResponse)?.statusCode {
if statusCode == 200 {
completionHandler(data, nil)
}
else {
completionHandler (nil, "Message")
}
}
else {
completionHandler (nil, "Invalid response")
print("!! Error - Downloading EPG Config")
}
})
dataTask.resume()
}
}
我米怎么回事错
这可能是由于服务器端缓存或使用代理cdn(如cloudflare),您是否尝试过使用类似邮递员的方式单独提出请求? – Scriptable