Question

Symptom: Reading an updated online XML file gives cached copy until app re-started. In Firefox on the Mac, it shows the updated version.

Part of the problem could be that I initWithContentsOfURL from a URL that ends with .php? This is a script that returns the XML data in Apple Plist 1.0 format. It all works fine, and I've checked that the initWithContentsOfURL is called every single time I press the Refresh button in the app.

But there seems to be nothing more I can do in the app to make sure uncached data is loaded when the user presses my Refresh button.

Is there still something I can change in the app to make it discard the cached data? Or is the only option left to add some no-cache meta tag to the XML (is that even possible?)

Was it helpful?

Solution

Add a cachebuster:

NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"http://domain/xml.php?_cacheBuster=%.0f", [[NSDate date] timeIntervalSince1970]]];
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top