arc:cache
Version 24.2.9039
Version 24.2.9039
arc:cache
The arc:cache keyword allows you to cache the output of a script or a template. Caching helps throttle the execution of resource-intensive scripts whose output is not expected to change. You can cache the output to a file for a specified duration or cache the output in memory. You can use priority-based or time-based caching.
Parameters
- file: The name of the file to which the output is cached. To cache to a file, you must also specify the duration or dependency parameter. To cache different versions of output for different input parameter values, include the parameter values in the file name.
- key: The key used to store the output of a script in an in-memory cache. To cache in-memory, you must specify this parameter. As with the file parameter, you can use script variables to differentiate between cache objects.
- duration: The duration specified in minutes. You can use this to cache for a fixed time and then refresh the contents of an object cached in-memory or a file.
- priority: The priority to use while caching to an in-memory cache. This parameter is only valid if key is also specified. Valid values are
Low
,BelowNormal
,Normal
,AboveNormal
,High
, andNotRemovable
. - update: Whether the arc:cache statement should refresh the cache on invocation. The default is
false
. - format: The cache file format: SQLite or RSS. The default is
RSS
. - table: The table in the SQLite database where the output is cached.
- dependency: The mapping to the ASP.NET cache dependency. When the specified file changes, the object in the cache is removed. This file or directory maps to
System.Web.Caching.CacheDependency(fileOrDir)
.
Control Attributes
None
Examples
Create an XML file for each customer type. Use the tofilename formatter to ensure that the resulting name can be used as a file name.
<arc:cache duration="10" file="cache_[customer_type |tofilename].xml"/>
Cache customer_type
records in-memory, instead of to a file:
<arc:cache priority="Normal" key="cache_[customer_type]"/>
Create a new cache object for each state specified in the request:
<arc:cache key="cache_[_request.state]"/>