How to disable caching in Alamofire

You have a few options.

Disabling the URLCache Completely

let manager: Manager = {
    let configuration = NSURLSessionConfiguration.defaultSessionConfiguration()
    configuration.URLCache = nil
    return Manager(configuration: configuration)
}()

Configuring the Request Cache Policy

let manager: Manager = {
    let configuration = NSURLSessionConfiguration.defaultSessionConfiguration()
    configuration.requestCachePolicy = .ReloadIgnoringLocalCacheData
    return Manager(configuration: configuration)
}()

Both approaches should do the trick for you. For more information, I'd suggest reading through the documentation for NSURLSessionConfiguration and NSURLCache. Another great reference is NSHipster article on NSURLCache.


This is what worked for me.

NSURLCache.sharedURLCache().removeAllCachedResponses()

Swift 3

URLCache.shared.removeAllCachedResponses()