arc:cache

Version 23.4.8839


arc:cache

Version 23.4.8839


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 specify either the duration parameter or dependency parameter in addition to the file parameter.

    To cache different versions of output for different input parameter values, include the parameter values in the file name.

  • key: The key that is used to store the output of a script in an in-memory cache. To cache in memory, you must specify the key parameter.

    Similar to the file attribute, you can use script variables to differentiate between cache objects.

  • duration: The duration specified in minutes. It can be used to cache for a fixed time and then refresh the contents of either an object cached in memory or a file.
  • priority: The priority to use while caching to an in-memory 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.
  • update: Whether the arc:cache statement refreshes the cache on invocation. The default is false.
  • format: The file format of the cache: 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. The tofilename formatter is used 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, rather than 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]"/>