I am trying to use etag to cache my images, the first time it loads all the images, as if it repeated the second time that it had to enter a failed block with 304.
I tried to make a request from outside, and I get 304, as it should, I just have problems with AFNetworking.
NSString *urlString = [API_BASE_URL_PHOTOS stringByAppendingPathComponent:[photo getPathToPhoto]]; NSString *properlyEscapedURL = [urlString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; NSURL *url = [NSURL URLWithString:properlyEscapedURL]; NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url]; if ([UserDefaultManager getEtagForKey:photo.nom] != nil) { [request setValue:[UserDefaultManager getEtagForKey:photo.nom] forHTTPHeaderField:ETAG_IF_NONE_MATCH]; } [request setHTTPMethod:API_METHOD_GET]; AFImageRequestOperation *operation = [AFImageRequestOperation imageRequestOperationWithRequest:request imageProcessingBlock:nil success:^(NSURLRequest *request, NSHTTPURLResponse *response, UIImage *image) { [FileUtils createDirectoryInDocumentsWithFileName:photo.folderName]; NSString *docPath = [FileUtils getPathInDocumentsWithFileName:[photo getPathToPhoto]];
source share