{"action":"closed","issue":{"url":"https://api.github.com/repos/AFNetworking/AFNetworking/issues/3800","repository_url":"https://api.github.com/repos/AFNetworking/AFNetworking","labels_url":"https://api.github.com/repos/AFNetworking/AFNetworking/issues/3800/labels{/name}","comments_url":"https://api.github.com/repos/AFNetworking/AFNetworking/issues/3800/comments","events_url":"https://api.github.com/repos/AFNetworking/AFNetworking/issues/3800/events","html_url":"https://github.com/AFNetworking/AFNetworking/issues/3800","id":192076087,"number":3800,"title":"Image caching not working","user":{"login":"vikram-gupta","id":7363044,"avatar_url":"https://avatars.githubusercontent.com/u/7363044?v=3","gravatar_id":"","url":"https://api.github.com/users/vikram-gupta","html_url":"https://github.com/vikram-gupta","followers_url":"https://api.github.com/users/vikram-gupta/followers","following_url":"https://api.github.com/users/vikram-gupta/following{/other_user}","gists_url":"https://api.github.com/users/vikram-gupta/gists{/gist_id}","starred_url":"https://api.github.com/users/vikram-gupta/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vikram-gupta/subscriptions","organizations_url":"https://api.github.com/users/vikram-gupta/orgs","repos_url":"https://api.github.com/users/vikram-gupta/repos","events_url":"https://api.github.com/users/vikram-gupta/events{/privacy}","received_events_url":"https://api.github.com/users/vikram-gupta/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2016-11-28T18:06:30Z","updated_at":"2016-12-05T05:59:42Z","closed_at":"2016-12-05T05:59:42Z","body":"I am using the following code to download an image file from Amazon S3. I also wanted to cache the images and thus added the caching policy in the `NSURLRequest`. I have been able to download the images nicely but the caching is not working.\r\n\r\n\r\n\r\n```\r\n    NSURLRequest *request = [NSURLRequest requestWithURL:url cachePolicy:NSURLRequestReturnCacheDataElseLoad timeoutInterval:60];\r\n    \r\n    NSURLSessionDownloadTask *downloadTask = [afUrlSessionManager downloadTaskWithRequest:request progress:nil destination:^NSURL *(NSURL *targetPath, NSURLResponse *response) {\r\n        return destinationUrl;\r\n    } completionHandler:^(NSURLResponse *response, NSURL *filePath, NSError *error) {\r\n        NSLog(@\"AssetDownloader:Asset downloaded to: %@\", [destinationUrl path]);\r\n    }];\r\n    \r\n    [downloadTask resume];\r\n```\r\n\r\nTo debug, I implemented a CustomURLCache class which has been inherited from `NSURLCache`, so that i can monitor the retrieval and storage events on the cache. However, I am not able to get this up and running. The following method gets called when I request for downloading a file using the `downloadTaskWithRequest:request`.\r\n\r\n`- (nullable NSCachedURLResponse *)cachedResponseForRequest:(NSURLRequest *)request;`\r\n\r\nHowever, the following method never gets called and thus nothing gets written into the cache.\r\n\r\n```\r\n- (void)storeCachedResponse:(NSCachedURLResponse *)cachedResponse\r\n                 forRequest:(NSURLRequest *)request;\r\n```\r\n\r\nI read at couple of places that if the \"cache-control\" header is not present in the response, the client would not do any caching. Here are the response headers. Cleary, \"cache-control\" is missing.\r\n\r\n```\r\nAccept-Ranges →bytes\r\nContent-Disposition →attachment\r\nContent-Length →129569\r\nContent-Type →application/zip\r\nDate →Mon, 28 Nov 2016 17:13:27 GMT\r\nETag →\"5d065d636b3bd4789737664af7456b62\"\r\nLast-Modified →Wed, 23 Nov 2016 08:52:01 GMT\r\nServer →AmazonS3\r\n```\r\n\r\nIs this the main reason for the issue? If yes, what can I do as I have no control over the server?\r\n\r\n\r\n\r\n"}}
{"actor":{"display_login":"vikram-gupta"}}