Alamofire: cache large files downloaded to the Documents folder

Viewed 1539

I use this piece of code to download MP3 files to the documents directory:

let destination = DownloadRequest.suggestedDownloadDestination(for: .documentDirectory)
Alamofire.download(theUrl!, to:destination).response { response in
    // stuff
}.downloadProgress { progress in
    // Stuff
}

The file downloads fine, but if i close the app and start it again, the download restarts from 0. What i want is for the file to be cached and fetched immediatly. My understanding of Alamofire is that the file is downloaded to a temporary folder and then moved to the Documents folder, is this what causes the cache to not happend ?

Thanks a lot

1 Answers
Related