Processors - Cache Processor


You can compare the Cache processor to the Identity processor:
  • The Cache processor is similar to the Identity processor as it has a data input and a data output, and the data output is a copy of the data input.
  • It differs from the Identity processor as it has a key and a validity inputs, for you to change the caching information associated with the input document.
The two additional inputs can be described as follows:
  • key input - It contains a document (in any format) which identifies the document. This will typically be a subset of the data document.
  • validity input - It contains a <validity> element, which either contains:
    • The string none
      • Indicates the document is not cacheable.
    • Nothing (empty element)
      • Indicates that the document is valid forever.
    • A XML Schema duration
      • For instance PT1H for "1 hour"
      • Indicates that document is valid for the specified duration.
    • An XML Schema date or dateTime
      • Indicates a time stamp for the document.
      • The time stamp is assumed to be the current time or to be in the past.
      • Other documents with the same key will considered to be same as this one unless they have a time stamp which is after this time stamp.
      • If no timezone is specified, the System's default timezone is used.

Use cases

Prevent caching

You have a pipeline with two processors: the request generator and XSLT. The request processor feeds the request to XSLT. The output of your pipeline will be cacheable based on the request document; i.e. if the request doesn't change the output of your stylesheet might be cached, so the stylesheet doesn't have to run at all if the engine "already knows" the result of the stylesheet for that request. But in your stylesheet you are calling some Java code which has side effects. So you want the stylesheet to run every time. You can obtain this result by adding the cache processor after the XSLT processor:

<p:processor name="oxf:cache">
    <p:input name="data" href="#..."/>
    <p:input name="key"><dummy/></p:input>
    <p:input name="validity"><validity>null</validity></p:input>
    <p:output name="data" ref="..."/>

Cache database result

You are retrieving some information from a database with the SQL processor.  By default, the output of the SQL processor is not cacheable. This assumes, to be conservative, that if you are running the exact same query against a database twice, two different result might come back, as the database might have been updated between the two queries.

Your system provides flight status information, and the query returns the status for a given flight. That information might change in the database at any time, but you are OK providing to users information which is at most 1 minute old, to avoid 1000 request coming in the same minute to result in a 1000 hits on your database. So you use the Cache processor to specify that the data is valid for 1 minute:

<p:processor name="oxf:cache">
    <p:input name="data" href="#..."/>
    <p:input name="key">
    <p:input name="validity">
    <p:output name="data" ref="..."/>


If using a build post 2011-10-12, the processor is already included in Orbeon Forms.

With older builds, add the attached jar file to your WEB-INF/lib. Add the following declaration to your config/processors-local.xml (or create this file if it does not exist):

<processors xmlns:oxf=""
    <processor name="oxf:cache">
        <class name="org.orbeon.oxf.processor.CacheProcessor"/>

Erik Bruchez,
Jul 25, 2008, 3:57 PM
Erik Bruchez,
Jul 25, 2008, 3:59 PM