简体   繁体   English

iOS-禁用Alamofire缓存参数

[英]iOS - Disable Alamofire Cache parameters

does Alamofire also cache request parameters? Alamofire是否也缓存请求参数?

after doing a login request, i open my cache.db and it reveals my username and password parameters. 在执行登录请求后,我打开我的cache.db,它显示了我的用户名和密码参数。

is it default for alamofire to cache request parameters or it's just my misconfiguration ? alamofire默认缓存请求参数还是仅仅是我的配置错误?

is there any way to disable caching just for the parameters. 有什么方法可以禁用仅针对参数的缓存。 because currently i enable caching just for .GET request since it doesn't have parameters 因为当前我只为.GET请求启用缓存,因为它没有参数

You can disable any kind of caching as below, 您可以按以下方式禁用任何类型的缓存,

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {

    let emptyCache = URLCache(memoryCapacity: 0, diskCapacity: 0, diskPath: nil)
    URLCache.shared = emptyCache

    return true
}

您可以按以下方式禁用alamofire中的缓存。

Alamofire.Manager.sharedInstance.session.configuration.requestCachePolicy = .ReloadIgnoringLocalCacheData

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM