ObjectContext always returns a cached object?

Sep 6, 2010 at 5:48 PM

I'm running into an issue where making a query to get a fresh copy of some data is returning the previously fetched object. This appears to be intention, but not what I would expect. The behavior I'm talking about is in ObjectContext -addToObjectToResource:atomEntry:.

The OData client keeps a cache of all objects it has retrieved. On subsequent queries, after it has downloaded the response results from the server, it looks to see if it already has an object in its cache with same identity. If so, it will return the previously fetched object instead of generating a new one with the latest data from the server.

 

But doesn't this cause a problem? If the server version of the object is newer than what I previously fetched, I'm still going to get the old version, not the new. Am I missing something? How do I get a fresh copy of an object?

 

 

Jan 18, 2011 at 10:57 PM

There are several ways that the user can control caching in the HTTP header: one is to use the Cache-Control field: set it to no-cache. Another is to use the If-Modified-Since field.  If a server does not conform to HTTP standards, it is a problem of that server and not of this client utility.