Pipeline caching

Because both content and the XSL transforms used to process the content may be re-used frequently, DCI supports both content and XSLT caching.

Because both content and the XSL transforms used to process the content may be re-used frequently, DCI supports both content and XSLT caching.

Caching pipeline content

Content caching is a simple, general purpose caching method that supports both simple cache keys, and multiple attribute keys that are matched with template parameter values. Once executed, the cache is held until the application server is stopped or restarted.

The pipeline:cache element is the container for content cache definition. The cache stores objects based on the key attribute, or in the case of multiple keys the pipeline:cacheKey element. The key is then counted and used as a reference against the cache size. The cache uses the least-recently-used strategy for handling its content which is contained in the pipeline:cacheBody element.

The pipeline:cacheControl element has a timeToLive attribute containing the length of time in seconds that the entry is valid from the time it enters the cache. The example shows it set to 600 seconds (10 minutes).

<?xml version="1.0" encoding="UTF-8"?>
<html xmlns="http://www.w3.org/2002/06/xhtml2"
  xmlns:pipeline="http://www.volantis.com/xmlns/marlin-pipeline"
  xmlns:webd="http://www.volantis.com/xmlns/marlin-web-driver">
  <head>
    <title>Pipeline cache</title>
  </head>
  <body>
    <div>
      <pipeline:cache name="jiveCache">
        <pipeline:cacheInfo>
          <pipeline:cacheKey value="weatherConditions"/>
          <pipeline:cacheControl timeToLive="600"/>
        </pipeline:cacheInfo>
        <pipeline:cacheBody>
          <pipeline:transform href="test.xsl" cache="true" compilable="false">
            <webd:get url="http://weather.yahooapis.com/forecastrss">
              <webd:parameters>
                <webd:parameter name="p" value="USWA0395"/>
                <webd:parameter name="u" value="c"/>
              </webd:parameters>
            </webd:get>
          </pipeline:transform>
        </pipeline:cacheBody>
      </pipeline:cache>
    </div>
  </body>
</html>
Note:

You can flush either a named pipeline cache or all pipeline caches with the mcsServerManager CLI.

Caching transforms

The pipeline:transform defines the caching of individual XSL transforms, and provides functions for compiling the transform.

Together with the setting of the compile attribute on the transform element in the pipeline-configuration section of mcs-config.xml file, the compilable attribute specifies whether the XSL transform should be compiled or not. If both values are 'true', the transform is compiled.

Configuring pipeline caches

Cache configuration parameters are contained in the pipeline-configuration section of the mcs-config.xml file.

Content caching is defined by the caching-operation and cache elements. The name and max-entries attributes on the cache element are required.

The expiry-mode attribute on the caching-operation element may be used to track dependencies in dynamic content, and take these into account when working out when the cache expires. A value of 'fixed-age' will not track dependencies. A default value of 'auto' will turn tracking on. This global value may be overridden at pipeline:cache element level.

Note:

The attributes enable-caching and max-cache-entries on the connection element may be used to enable or disable caching and set the cache size for responses to urid-fetch requests.

<caching-operation>
  <cache name="jiveCache"
    max-entries="10"
    strategy="least-recently-used"/>
</caching-operation>

You configure the transform cache with the transform element. The cache attribute controls whether templates will be cached. Templates are the internal structures, created from XSLT markup, which actually do the transformation. Construction of a template from the XSLT markup is quite a costly operation so caching them can improve performance significantly.

If this attribute is false then templates are never cached. Otherwise they are cached using a composite key constructed from the fully resolved URL and the compilable attribute value. Templates that are created from XSLT markup inline within the page do not have an associated URL and hence are not cacheable.

The size of the cache cannot be configured and is unlimited in size, meaning that templates are never removed.

If the compile attribute is set to 'true', pipeline:transform and pipeline:transformation elements whose compilable attribute are also set to 'true' are cached. If the compile attribute is set to 'false', no attempt is made to compile transforms.

Note:

Care must be taken when changing this attribute from its default value as XSLT compilers are not yet capable of handling all XSLT constructs.

<pipeline:transform compilable="false" cache="true"/>

Caching templates

Construction of a template is quite a costly operation and in fact for smallish XSLTs can actually exceed the cost of the transformation itself. Therefore, caching templates can have a significant performance benefit. Two related methods, setTemplateCache and getTemplateCache are available in the public API.

Related topics