                     self.loadImageFromFileAsync()
                 })
             }else if let url = photoURL {
-                let request = NSURLRequest(URL: url, cachePolicy: NSURLRequestCachePolicy.ReturnCacheDataElseLoad, timeoutInterval: 0)
-                let getImageTask = downloadSession.downloadTaskWithRequest(request)
-                getImageTask.resume()
+                let key = "\(url.hash)"
+                let CacheCenter = SDImageCache.sharedImageCache()
+                if let cache = CacheCenter.imageFromDiskCacheForKey(key) {
+                    aUnderlyingImage = cache
+                    imageLoadingComplete()
+                    return
+                }
+                SDWebImageDownloader.sharedDownloader().downloadImageWithURL(url, options: SDWebImageDownloaderOptions.ContinueInBackground, progress: { (read, total) -> Void in
+                    let progress = CGFloat(read)/CGFloat(total)
+                    dispatch_async(dispatch_get_main_queue(), { () -> Void in
+                        progressUpdateBlock?(progress)
+                    })
+                }, completed: { (img, data, err, flag) -> Void in
+                    if let image = img {
+                        self.aUnderlyingImage = image
+                        self.imageLoadingComplete()
+                        CacheCenter.storeImage(image, forKey: key, toDisk: true)
+                    }
+                    
+                })
+                
             }
         }
         

    private var aUnderlyingImage: UIImage!
    private var loadingInProgress: Bool!
    public var  photoPath: String!
    private var downloadSession: NSURLSession!
    
    
    convenience public init(image: UIImage) {

    
    override init() {
        super.init()
    }
}
// MARK: - NSURLSessionDelegate
