开发者

NSURLRequest odd behaivor

I'm having such an odd problem. I'm running iOS 4.3.2 on my device. Compiling in Xcode 4 but I am not using the iOS 5 beta SDK.

My app fetches a plist file from a server, the plist file is set of strings I use in my app.

I get the data via a request and connection like so

    NSURLRequest *req = [[NSURLRequest alloc] initWithURL:[NSURL URLWithString:pathAndFile]
                                        cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:60.0];
NSURLConnection *con =[[NSURLConnection alloc] initWithRequest:req 
                                                      delegate:self];

When running on wifi - if I go up and make a change on the server side, the app will see the new data and use it each time the app i开发者_如何学Gos launched.

If I switch my phone over to 3G it goes and grabs the data correctly the FIRST TIME. If I then go back and change the file on the server, and rerun the app - it is only loading the OLD data, not the new data. The app IS hitting the code where the connection is established and loaded.

Ok, so now I'm in this state where the app is using old data. I switch the phone to wifi and BAM, the new data is there.

But if I now close the app. Turn off wifi. Launch the app, the app is using the OLD DATA again.

I did implement

- (NSCachedURLResponse *)connection:(NSURLConnection *)connection willCacheResponse:(NSCachedURLResponse *)cachedResponse {
return nil;

}

as suggested in another stackoverflow thread. Anybody have any thoughts why this could be happening and how I could make it work correctly?


I am just throwing this out there as something to check:

I have a hard time believing this but perhaps your 3G carrier is caching? Can you check your server logs to see if you are receiving the actual calls from the device? If not, try concatenating an random querystring value on the end of the URL on every request and then check the server logs again.

Hope this helps.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜