util:cache

Use this tag to cache a block of JSP code. Typically, you use this around code that is resource hungry, such as iterating through 200 sections. Use the JSP statistics functionality to guide you in using this tag.

To explicity expire a cached block (before the cache tage's own expire time), you can to use these tags:

  • <article:expiresCache>

  • <section:expiresCache>

Be careful not to create nested <util:cache> elements as this may cause significant performance problems. Beware of templates calling/including other templates where the caller has a <util:cache> around the callee, which itself also has a <util:cache> element.

If you get a JSP with <util:cache> taking just over 10 seconds to render, typically 10023ms, it is probably because of nested <util:cache> elements.

See also

article:expiresCache, section:expiresCache

Syntax
<util:cache
   blocking="..."?
   blockingTimeout="..."?
   expireTime="..."?
   id="..."
   includeArticle="..."?
   includeSection="..."?>
   ...
</util:cache>
Attributes
id, mandatory

Each cached fragment must have an id. The id is used to identify thecached fragment.

The id can be any string. If two or more instances of the cache tag have identical ids, they will share the cached content as well.

Typically you want to create a unique id for every instance of the cache tag. You can do so for example by using section ids,article ids, string constants, or a combination of them.

includeArticle

Will make it easier to create a unique id. If set to true the tag will automaticly include the current article into the key.

The tag will handle if there is no current article, but the id will not be unique.

Default it is set to false.

includeSection

Will make it easier to create a unique id. If set to true the tag will automaticly include the current section into the key.

The tag will handle if there is no current section, but the id will not be unique.

Default it is set to false.

expireTime

Sets the how long we will wait until the cached items are expired from the cache. The time is by default in minutes. You can changed that to seconds, minutes or hour by adding a s,m or h after wanted time.

e.g. 120s means 120 seconds and 2h means 2 hours

Please note that setting the attribute to 1 second as this is not the same as disabling the cache.

blockingTimeout

Sets how long we will wait for the cached item to be created. This is only relevant during system startup. The only reason to set this, is if you have got a resource that normally takes more time than the default value to create. The value is in milliseconds. Set to 0 to block forever, but this may potentially lock your system and should be avoided.

Default is 10 seconds.

blocking

Set this to "false" to avoid waiting for a cached item to finish loading. This will leave the cached part of the page empty. This option is only relevant during startup of the system.

Default is to block waiting for the cached item to finish. Timeout is set with blockingTimeout.