Caching Service Data in a Mashup
You can enable caching data for services that are used to retrieve data in a mashup. Caching helps reduce the number of network requests to the server, which improves performance and user experience. For example, caching a service that takes several seconds to load can reduce network, especially when the service is executed frequently and the returned data does not change often. When caching is enabled and the CacheDuration property is set, the service result is stored temporarily by the browser until the cache expires after the specified duration.
Enabling Caching for Services in a Mashup
To enable caching for a service in a mashup, follow these steps:
1. In Mashup Builder, open the Data panel, then select the data service that you want to cache to view its data properties.
2. On the Data Properties panel, under Advanced, select the check box next to the CacheReturnedData property.
3. Specify the number of milliseconds to keep the result stored using the CacheDuration property.
4. Optionally, specify the cache storage strategy using the CacheStrategy property.
5. To cache results for specific parameters inputs, select the parameter from the drop-down list of the CacheKeyParameters values.
6. Click Save, then View Mashup.
At runtime, the service data is cached when the service is executed for the first time. Any data returned based on input parameters that are selected for the service using the CacheKeyParameters property are cached. When the service is executed again, the data is retrieved from the stored cache until the time set in CacheDuration expires.
Choosing a Caching Strategy
You can use the CacheStrategy property to store the cached data in one of two ways:
Mashup Instance— A cache is generated based on a unique identifier for the current mashup instance. Use this strategy to ensures that each instance of a mashup has a separate cache, which is useful when each mashup instance displays different data, even when the entity and service are the same.
Mashup Name—A cache is generated based on the mashup, entity, and service names. Use this strategy when the same data is expected to be displayed across multiple instances of a mashup, such as in a Collection widget or when a mashup is embedded within other mashups. This strategy is less specific than instance caching and the cache is shared across all instances of the same mashup.
Service Caching Properties
The following table list caching properties that are available for services on the Data Properties panel.
Property
Description
Base Type
Default Value
CacheReturnedData
Enable this to cache the data returned from the server.
BOOLEAN
False
CacheDuration
Sets the time to live duration for cached data in milliseconds. When data is cached, new data is retrieved from the server only after the duration expires.
INTEGER
CacheStrategy
Controls the way that cache is stored. You can choose to store the cached results based on the Mashup Instance or the Mashup Name.
STRING
Mashup Instance
CacheKeyParameters
Opens a drop-down list that enables you to select the input parameters to use for generating the cache key. When a service input parameter is selected, the service results for that input are cached.
STRING
MaxResultSets
Controls the maximum number of results to store for the data service. A new result is cached when the input parameters are updated. The oldest result is deleted when the maximum is reached.
INTEGER
10
Was this helpful?