我遇到了一个Alamofire的问题,我对不同的请求得到了相同的响应。我使用以下方法来请求:
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很多,从来没有遇到过这个问题。
Alamofire版本: 4.1 Xcode版本: 8.3.3 Swift版本: 3.1运行Alamofire的平台:运行Xcode的iOS macOS版本: 10.12.5
发布于 2017-07-08 01:29:13
您可以在发出alamofire请求之前清除缓存。
NSURLCache.sharedURLCache().removeAllCachedResponses()执行此命令后,调用alamofire request。
https://stackoverflow.com/questions/44976454
复制相似问题