The rsb:cache keyword allows you to cache the output of a script or a template. You can cache the output to a file for a specified duration or cache it in memory using the ASP.NET object caching. If you choose to cache to a file you must specify the file and the duration parameters, and if you choose to use ASP.NET cache you must specify the key parameter. You can also use the priority or the duration parameter with the key parameter to use priority based or time based caching.
Caching helps throttle the execution of resource-intensive scripts whose output is not expected to change. rsb:cache has the following parameters:
- duration: The duration is specified in minutes. It can be used to cache for a fixed time and then refreshing the cached contents of either a file or an ASP.NET cached object.
- file: The parameter file is the name of the file to which the output is cached. The file contents are automatically refreshed once the specified duration expires, and are used to serve subsequent requests. To cache different versions of output for different input parameter values, include the parameter value(s) in the filename. For example, to cache a different output for each "customer_type" (an input parameter), you can use the parameter as part of the file name.
- key: The key that is used to store the output of a script in the ASP.NET cache. Just like the file attribute you may use script variables to differentiate between cache objects. For e.g. key="cache_[_request.state]" will create a new cache object for each state specified in the request.
- priority: The priority to use while caching to ASP.NET cache. The priority parameter is only valid if key is also specified. The valid values for priority are: Low, BelowNormal, Normal, AboveNormal, High, and NotRemovable.
This keyword does not have a scope and thus does not have any control attributes.
Note: We used the "tofilename" formatter to ensure that the resulting name can be used as a filename.<rsb:cache duration="10" file="cache\[customer_type |tofilename].xml"/>
See the section Improving Performance to learn how best to utilize cached feeds.<rsb:cache priority="Normal" key="cache_[customer_type]"/>