0

I have been working on this issue for hours now, and I cannot figure it out.

My server creates a WSDL file which a user can update with new functions and the WSDL file will update to reflect those changes. I am using an AFHTTPRequestOperation with GET to grab that file so I can check which functions exist in the file.

For some reason, after a user updates the file and regenerates it, the AFHTTPRequestOperation is still seeing the old version (cached?), but if I view that same URL in my browser, not logged into my site or anything, it shows the new version of the file. Even trying wget grabs the new copy.

I am making sure to use NSURLRequestReloadIgnoringLocalAndRemoteCacheData on my NSMutableURLRequest but it doesn't seem to matter:

// Setup the connection
NSString *wsdlURL = [NSString stringWithFormat:@"%@?WSDL", site.soapURL];
NSURL *serviceUrl = [NSURL URLWithString:wsdlURL];
NSMutableURLRequest *serviceRequest2 = [NSMutableURLRequest requestWithURL:serviceUrl cachePolicy:NSURLRequestReloadIgnoringLocalAndRemoteCacheData timeoutInterval:60.0];
[serviceRequest2 setHTTPMethod:@"GET"];

// Create the operation
AFHTTPRequestOperation *operation2 = [[AFHTTPRequestOperation alloc] initWithRequest:serviceRequest2];
[operation2 setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation2, id responseObject2) {

    // Convert data to string
    NSString *wsdlStr = [[NSString alloc] initWithData:(NSData *)responseObject2 encoding:NSUTF8StringEncoding];

} failure:^(AFHTTPRequestOperation *operation2, NSError *error) {
    failure(error);
}];
[operation2 start];

Does anyone know why it would be getting the old copy of the file? And the browser shows the new one?

Nic Hubbard
  • 41,587
  • 63
  • 251
  • 412

1 Answers1

0

I realized I needed to add the following to the request:

[serviceRequest2 setValue:@"no-cache" forHTTPHeaderField:@"Cache-Control"];
Nic Hubbard
  • 41,587
  • 63
  • 251
  • 412