title: iOS: forcing server to provide updated data
body: <p>I'm working on an iPad app that requests data from a server, changes and submits it, and then re-requests the data from the server, displaying it to the user. The app updates the data just fine (the equivalent web app sees the update happening), but the data that the iPad app gets back is the old data. I thought maybe it was the caching flag on the NSURLRequest, but it doesn't look like it. </p>
  
  <p>Here is my sequence of calls:  </p>
  
  <pre><code>NSString* currentStuff = self.fCurrentIndex.currentStuff;
  NSError* err = nil;
  [self.fCurrentIndex approve:currentStuff withUsername:username andPassword:password error:&amp;err];
  
  if (err == nil)
  {
      // rebuild the case list (grab the data from the URL again first)
      [self getCaseListViaURL]; // grab the updated data
      [self setupUIPanel]; // display it
  }
  </code></pre>
  
  <p>Here's the code that grabs the data (the 'getCaseListViaURL' call):  </p>
  
  <pre><code>NSURLResponse* response;
  NSError* err = nil;
  NSMutableDictionary * jsonObject = nil;
  NSString * urlRequestString;
  
  urlRequestString = [method to get the URL string];
  
  NSURL * url = [NSURL URLWithString:urlRequestString];
  NSURLRequest * request = [NSURLRequest requestWithURL:url
                                            cachePolicy:NSURLRequestReloadIgnoringLocalCacheData
                                        timeoutInterval:60];
  
  NSData * data = [NSURLConnection sendSynchronousRequest:request
                                        returningResponse:&amp;response
                                                    error:&amp;err];
  
  if (err == nil)
  {
      jsonObject = [NSJSONSerialization JSONObjectWithData:data
                                                   options:NSJSONReadingMutableContainers
                                                     error:&amp;err];
  }
  
  if (err &amp;&amp; error) {
      *error = err;
  }
  
  return jsonObject;
  </code></pre>
  
  <p>Is there any way to force the server to serve up the updated data?</p>
  
  <p>Thanks in advance.</p>
  
  <p>EDIT: Per comments, I'm adding the sequence of update to the server and subsequent pull:</p>
  
  <p>This does the push to the server:</p>
  
  <pre><code>NSString* currentStuff = self.fCurrentIndex.currentStuff;
  NSError* err = nil;
  [self.fCurrentPatient approveStuff:currentStuff withUsername:username andPassword:password error:&amp;err];
  </code></pre>
  
  <p>Where 'approveStuff' eventually calls:  </p>
  
  <pre><code>__block NSData * jsonData;
  __autoreleasing NSError * localError = nil;
  
  if (!error) {
      error = &amp;localError;
  }
  
  // Serialize the dictionary into JSON
  jsonData = [NSJSONSerialization dataWithJSONObject:data
                                             options:NSJSONWritingPrettyPrinted
                                               error:error];
  if (*error) return nil;
  
  NSURLResponse* response;
  NSString * urlRequestString;
  
  urlRequestString = [self urlStringForRelativeURL:relativeURL
                                   withQueryParams:params];
  
  NSURL * url = [NSURL URLWithString:urlRequestString];
  NSMutableURLRequest * request;
  request = [NSMutableURLRequest requestWithURL:url
                                    cachePolicy:self.cachePolicy
                                timeoutInterval:self.timeOutInterval];
  [request setHTTPMethod:@"POST"];
  [request setHTTPBody:jsonData];
  [request setValue:@"application/json;charset=UTF-8" forHTTPHeaderField:@"Content-Type"];
  
  jsonData = [NSURLConnection sendSynchronousRequest:request
                                   returningResponse:&amp;response
                                               error:&amp;localError];
  NSMutableDictionary * jsonObject;
  
  if (localError == nil)
  {
      jsonObject = [NSJSONSerialization JSONObjectWithData:jsonData
                                                   options:NSJSONReadingMutableContainers
                                                     error:&amp;localError];
  }
  
  if (error &amp;&amp; localError) {
      *error = localError;
  }
  
  return jsonObject;
  </code></pre>
  
  <p>Right after this, I call the aforementioned get call and rebuild the UI. Now, if I stick a breakpoint when I do the get, and check on the web server if the data is updated after the push, I see the data is there. However, when I let the get operation continue, it gives me the old data.</p>