NSURLConnection returns old data

In my application, I load JSON data using a method NSURLConnectionthat looks like this:

NSURLRequest *request = [[NSURLRequest alloc] initWithURL:
                                [NSURL URLWithString:@"theurl"]];
NSURLConnection *theConnection = [[NSURLConnection alloc] initWithRequest:request
                                                                 delegate:self];
[theConnection start];

I get and save the data in the method -didReceiveData:, but if I update my JSON file on my server, it NSURLConnectionstill gives me the old JSON, and the file is uploaded correctly to the server. Only if I remove the entire application from my iPhone (or iPhone Simulator) and rebuild the application, it will receive a new Json file.

Does anyone know a solution to this problem?

+5
source share
2 answers

NSURLRequest ( ) . JBAsyncImageView (: NSURLRequestReloadRevalidatingCacheData NSURLRequestReloadIgnoringLocalCacheData):

// Create request
self.imageRequest = [[NSURLRequest alloc] initWithURL:imageURL 
                                          cachePolicy:(self.cachesImage) ? NSURLRequestReturnCacheDataElseLoad : NSURLRequestReloadIgnoringLocalCacheData 
                                      timeoutInterval:self.downloadTimeoutInterval];

// Begin download
self.imageData = nil;
self.imageConnection = [[NSURLConnection alloc] initWithRequest:self.imageRequest 
                                                       delegate:self 
                                               startImmediately:YES];
+9

timestamp :

http://example.com/api.json?my=args&timestamp=2344992923
+5

All Articles