Configuring a Client Application to Support Response Caching
When response caching is enabled, the DCS runtime determines whether a particular service operation is configured for caching, and checks whether there is a cached response for that operation in the client cache. If a value exists, DCS does not call the operation. Instead, DCS returns the stored response data. For more information about implementing caching policy, see Configuring Caching Policy for an Operation.
If you configure a DCS service to implement the response caching policy, you must modify the client application to support this policy. You configure client-side response caching by adding the following configuration classes to the custom <dcs.clientCache> section of the configuration file:
- Microsoft.ConnectedIndustry.ClientCache.Configuration.CacheManagerSection
- Microsoft.ConnectedIndustry.ClientCache.Configuration.CacheServiceSection
- Microsoft.ConnectedIndustry.ClientCache.Configuration.CacheFilterSection
The following example shows the <dcs.client.Cache> section of the configuration file configured for response caching.
<configSections>
...
<sectionGroup name="dcs.clientCache">
<section name="cacheManager" type="Microsoft.ConnectedIndustry.ServiceModel.ClientCache.Configuration.CacheManagerSection, Microsoft.ConnectedIndustry.ServiceModel.ClientCache, version=1.0.0.0, Culture=neutral, PublicKeyToken=830d65091f775802"/>
<section name="cacheService" type="Microsoft.ConnectedIndustry.ServiceModel.ClientCache.Configuration.CacheServiceSection, Microsoft.ConnectedIndustry.ServiceModel.ClientCache, version=1.0.0.0, Culture=neutral, PublicKeyToken=830d65091f775802"/>
<section name="cacheFilter" type="Microsoft.ConnectedIndustry.ServiceModel.ClientCache.Configuration.CacheFilterSection, Microsoft.ConnectedIndustry.ServiceModel.ClientCache, version=1.0.0.0, Culture=neutral, PublicKeyToken=830d65091f775802"/>
</sectionGroup>
...
</configSections>
To enable your client application to import the response caching policy specified for a service, you must add the Microsoft.ConnectedIndustry.ServiceModel.ClientCache.ClientCacheBindingElement class to the list of policy importers in the <policyImporters> section of the <system.ServiceModel> configuration, as shown in the following example.
<system.serviceModel>
...
<client>
<metadata>
<policyImporters>
...
<extension type="Microsoft.ConnectedIndustry.ServiceModel.ClientCache.ClientCacheBindingElement, Microsoft.ConnectedIndustry.ServiceModel.ClientCache,Version=1.0.0.0,Culture=neutral,PublicKeyToken=31bf3856ad364e35" />
...
</policyImporters>
</metadata>
</client>
...
</system.serviceModel>
You must add a cache partition definition to the <cacheManager> section of the <dcs.clientCache> configuration with the same cache partition name specified in the cache policy implemented by the service. For example, if the service specifies a cache partition name of ServiceResponseCache, then you must add a partition with the name ServiceResponseCache to the <cacheManager> section
The following code example shows how to define a partition in the client configuration file. For more information on configuring cache partitions, see Configuring Service Endpoint and WS-Metadata Caching.
<dcs.clientCache>
<cacheManager>
<partitions>
<partition name="ServiceResponseCache" isolationLevel="">
<store location="Machine" database="CacheDatabase" table="DCSCache" encryption="true" />
<expiration absolute="" sliding="" />
<offlineExpiration absolute="" sliding=""/>
</partition>
</partitions>
</cacheManager>
<cacheFilter enabled="true" defaultPartition=" WeatherServiceCache " />
</dcs.clientCache>
The isolationLevel property specifies part of primary key that is used to uniquely identify a cache record for a given endpoint. The default isolation key is "ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ". If the cache database is shared between several applications or users on the machine, each application can provide its own unique cache isolation key in the configuration file. You can leave the isolationLevel property as an empty string if you don't want to specify an isolation key, or you can specify one of the property names in the Context object, such as BusinessChannel or AccountingDate. In this case cache entries are isolated based on the values in the Context object. You can specify nested properties in the Context object by using the period character. For example, you can specify Organization.Plant or Organization.BusinessUnit.