Search code examples
wcfcachingodatawcf-data-services

Does Microsoft.Data.Services.Client caches data?


We were using the System.Data.Services.Client (version 4 I guess) of Microsoft WCF Data Services. When we updated to the version 5.2 (Microsoft.Data.Services.Client dll), it seems that some caching mechanism has been inserted into the new version of WCF Data Services.

Because when we query the data services (OData) through browser, fresh data would be returned, but when we add a service reference to our UI project and use that reference (proxy) to retrieve data, only after 10 minutes or so the fresh data would be shown.

By resetting IIS (iisreset.exe) fresh data would be available, which probably means that somewhere in UI project a caching should be in place.

We don't do something extraordinary in our code, but using OData service reference in its most simple state:

public List<Customer> GetCustomers()
{
    CustomersODataModel customersData = new CustomersODataModel("Url");
    return customersData.ToList();
}

Solution

  • Consider disabling client side caching in the DataService object and see if that helps. I had the same problem and setting dataService.MergeOption to MergeOption = MergeOption.OverwriteChanges helped keep the data service refreshing the obejct on each change and get.