Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Div
idProductTOC

On this page

Table of Contents
maxLevel1
excludeOn this page
typeflat
separatorpipe

Section
Column
Excerpt

Caches rendered data to improve page display performance.

Caches the rendered contents of the body of this macro. Very useful when using macros that might be slow to render content, but where it does not really need to be dynamically generated for each and every request. Specifically, this can improve performance for accessing dynamic data from SQLExcel, and similar macros. Cache will be refreshed if the body of the macro changes or if attachments to this page have been added, removed, or have newer versions. The cache applies to all users that view the page. The cached content can optionally be indexed for Confluence search.Based on OSCache.

Warning
titleUser specific content

Do not use the cache macro around content that renders differently for different users. This is especially important for any content that is security sensitive.

Column
width50%

...

Table plus
ParameterDefaultMacro Browser LabelDescription
idautomatically generatedReference id

Defaults to an automatically generated sequence number. The id must be unique on the page. Specifying the id can improve performance during edit by reducing cache refreshes during macro browser refresh, preview, and save cycle. It also helps when re-ordering cache macros on a page. The can be used when doing cache macro specific refreshes - see Cache Refresh below. Since 5.1.0.

refresh

1d

(one day)

Cache refresh period

Cache will be refreshed the next time page is viewed after the refresh period. A unqualified number will be treated as seconds. A number followed by one of the following characters will be treated as follows:

  • s - seconds.
  • m - minutes.
  • h - hours.
  • d- days.

    Note

    Any data after a s, m, h, or d is ignored. For example, 10days is the same as 10d or 10 days.

cron Cron expressionCron-like expression for finer grained cache expiration and refresh. See Cron Expressions. For example: 30 * * * * - cache will expire 30 minutes past each hour of the day. This means the data shown will
checkAttachmentstrueCheck attachmentsIf true, the cache will be refreshed if there is any change in the attachments on this page. This includes adding, removing, or changing the version of any attachment. For instance, if you are caching the rendering of the an excel spreadsheet, then the data will be refresh if the attached spreadsheet is updated.
showRefreshfalseShow refresh iconWhen shown, the icon can be clicked to cause the immediate refresh of the data.
showDatefalseShow dateShow the date and time of data was last generated. See also dateFormat.
indexfalseIndex contentAdd cached content to the Confluence search index. Whenever the cached data is updated, the page will be re-indexed. This enables external content to be found using Confluence search.
titleRefreshTitleTitle to show when mouse is over the refresh icon.
dateFormatuser date formatDate formatDefaults to the system defined format modified by the users time zone. The refresh date can be have a specific format. Use simple date format string. Since 6.1.
anchor AnchorName of a page anchor used to position after refresh link is pressed. Use @default to have an anchor generated at the macro location. Since 6.7.
retryDefaultRetry featureSpecial handling for render errors that can be retried. See Retry Feature for more details. Since 6.8.

Customization

  • For normal usage, properties do not need to be changed.
  • Properties for the cache behavior are specified in .../WEB-INF/classes/oscache.properties.
  • The properties file no longer ships with Confluence, but can be created. The default without a specific property file is:

    No Format
    title.../WEB-INF/classes/oscache.properties
    cache.memory=true
    cache.capacity=1000
    
  • The capacity property equal to 1000 means that 1000 distinct renderings of the cache macro will be cached. Additional distinct renderings will replace previously cached entries. You should increase the capacity only if you used the cache macro in many places (over 1000) that are accessed regularly and the extra JVM memory used will be acceptable.
  • If your system is memory constrained, consider adding a configuration file to restrict memory usage by setting cache.capacity=100 or cache.capacity=250
  • The rendered html is cached, so normally that may be a few KB per entry See New Cache Management Options.

Usage

No Format
{cache}
Something to cache for a day
{cache}

...