Question

I'm using RestKit in my iOS app to get my data and map them to objects in Core Data. The call returns an ETag so whenever the data is the same I'm getting a 304 from the server and no data is transfered.

This works perfectly fine and I'm happy with it.

BUT when I log out of my app, I need to clear those objects from core data. That works as well.

Then I want to clear the cached response so that the next time I log in RestKit does NOT send an ETag and that I can get the data again. So I'm doing this:

[[NSURLCache sharedURLCache] removeAllCachedResponses];

but it doesn't work, I'm still getting a 304 and no data.

How should I delete the ETag info??

Was it helpful?

Solution

This is an HTTP protocol thing, not a RestKit thing, so you need to look at the underlying handling / storage. So, I would expect your code to work. I don't think AFNetworking creates its own cache instance, but it might - it's worth checking in the code.

You could create the NSURLRequest to send using RestKit and then set the cachePolicy to NSURLRequestReloadIgnoringLocalAndRemoteCacheData.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top