Ios 阿拉莫菲尔缓存问题
我在Alamofire上遇到了一个问题,对于不同的请求,我得到了相同的响应。我使用以下方法请求:Ios 阿拉莫菲尔缓存问题,ios,swift,caching,swift3,alamofire,Ios,Swift,Caching,Swift3,Alamofire,我在Alamofire上遇到了一个问题,对于不同的请求,我得到了相同的响应。我使用以下方法请求: self.ephemeralManager?.request("myurladdress.com", headers: headers) .authenticate(user: username, password: password) .responseJSON { response in print(
self.ephemeralManager?.request("myurladdress.com", headers: headers)
.authenticate(user: username, password: password)
.responseJSON { response in
print(response)
}
以下是SessionManager:
let configuration = URLSessionConfiguration.ephemeral
configuration.urlCache = nil
ephemeralManager = Alamofire.SessionManager(configuration: configuration)
当我第一次提出请求时,它按预期工作。不久之后,当我使用不同的用户名和密码再次发出请求时,我从上一个请求中获取响应数据。如果我重新启动应用程序或等待一段时间,请求将按预期工作
我假设这是一个缓存问题,但在发出请求之前清除缓存或关闭缓存的所有尝试都失败了
有什么我遗漏的吗?我使用过Alamofire很多次,从未遇到过这个问题
阿拉莫菲尔版本:4.1
Xcode版本:8.3.3
Swift版本:3.1
运行Alamofire:iOS的平台
运行Xcode:10.12.5的macOS版本您可以在发出alamofire请求之前清除缓存
NSURLCache.sharedURLCache().removeAllCachedResponses()
执行此命令后,调用alamofire请求。它对我无效。我以前试过,但我又试了一次,运气不好。
NSURLCache.sharedURLCache().removeAllCachedResponses()