     
     public func urlSession(_ session: URLSession, dataTask: URLSessionDataTask, willCacheResponse proposedResponse: CachedURLResponse, completionHandler: (CachedURLResponse?) -> Swift.Void){
         if self.error == nil {
-            if shouldCache {
+            let cachePolicy = dataTask.originalRequest?.cachePolicy
+            if cachePolicy == .returnCacheDataElseLoad {
                 completionHandler(proposedResponse)
                 return
             }

    
    
    private static let sharedInstance = WTURLSessionDelegate()
    var shouldCache = false
    
    //网址凭据
    var credential: URLCredential?

        let delegate = WTURLSessionDelegate()
        delegate.completionHandler = completionHandler
        delegate.credential = credential
        
        
        let configuration = URLSessionConfiguration.default
//        configuration.urlCache = URLCache.sharedURLCacheForRequests()
