cache

Last modified by Lucas Charpentier on 2026/10/27 10:27

Audit

Macro ID
cache
Source
XS
Type
Wrapper
Classification reason
The output is the wiki content the user types, parsed and kept for a time: the parameters only change how long and under which key it is kept, never what is shown, so it is classified with the wrappers, like its sibling async, html and content, even though it adds no decoration around the content.
Status
Reviewed
Criteria version
15.20
XWiki version
18.8.0
Audit date
2026-10-20
Auditor
Compared macros
html content

Sources

Where to gather the information the criteria are checked against, see Gather the sources.

SourceWhat it givesUsed forWhere
DocumentationParameters, default values and examples, including the most common exampleL2, L3, and the criteria measured with the most common examplehttps://extensions.xwiki.org/xwiki/bin/view/Extension/Cache%20Macro
Source codeHow the macro declares its parameters and content: types, groups, features, advanced and hidden flags, constraints, content type, inline supportC4, C5, C7, C8, C9, C13, E4, E6Not recorded yet: search GitHub
Macro descriptorWhat the Edit Macro dialog is built from, on design.xwiki.orgD1, D2, C1 to C9, E4Descriptor, list of macros with their categories
TranslationsThe name, description and parameter names in each languageD1, D2, D4, C1l10n.xwiki.org
Uses in XWiki pagesHow XWiki itself uses the macro, a realistic example when the documentation has noneL3, C2, C3, C6, C8, C9Search the xwiki organization on GitHub
Compared macrosThe audits of the macros of the same typeL1, D3html, content
Other sources specific to this macro
CriterionResultNotes
D1 wordingOKthe name "Cache" is the name of the technology, which the documentation lists under the developer macros, and the macro is in Development, so it is audited as a developer macro and a technical name is fine. The French name is the same word, which is also the French word.
D2 summaryKOthe description "Caches content." repeats the name and adds nothing: it does not say that the result of executing the content is kept for a time and then computed again, nor that the scripts of the content run only once, which is the main limit the documentation gives. A simple wrapper that repeats its name is still a KO.
D3 categoryOKthe macro is in Development only, like html, which fits a macro for developers. The sibling async, which also caches, is in Content, and its audit notes that users who know the technology look for the cache macro in Development. Recorded OK.
D4 quick-actionOKQuick Actions finds the macro first for "cache" and "Cache", and the German name "Pufferspeicher" comes first too. The French name is the same word as the English one, so it is not counted, and the German name is enough. The synonyms "cache content", "memoize output", "store rendering", "remember result", "cache result" and "save output" give nothing. For a technical macro named after its technology few synonyms finding it is acceptable, as for html and async. The Insert Macro dialog is not counted.
L1 consistencyOKcompared with html and content, the compared macros of async. Like html, the Quick Actions entry opens the Edit Macro dialog with a required Content text area, while content is inserted at once; an empty cache macro makes no sense, so the difference is by design. Like html, it is in Development.
L2 doc-parametersKOthe parameters are documented only on the legacy extensions.xwiki.org page, https://extensions.xwiki.org/xwiki/bin/view/Extension/Cache%20Macro, and there is no page in the new documentation, unlike its sibling async. The page lists id, timeToLive and maxEntries, and its defaults match the descriptor: the checker flags "300 seconds (5 minutes)" against 300, which is the same value. It does not list the content, and it gives a default for id, the content itself, that the descriptor leaves empty.
L3 doc-exampleKOminor: the audit example is Example 2 of the documentation, {{cache id="myuniqueid"}}content to cache here...{{/cache}} , the first example with real values, since Example 1 is a syntax template with placeholders, id="...", that fails with "ISPN000424: Memory eviction is enabled, please specify a maximum size or count greater than zero" when copied. Examples 2 to 6 render without error, but they all cache the text "content to cache here...": none shows the real use, the result of a slow script, which only the Limitations paragraph describes, and the GitHub code search of the xwiki organization found no call of the macro in XWiki Standard to compare with. Async shows its real uses, with velocity content, in its examples.
I1 patternKOcompared with warning, the reference wrapper, and with html. The Quick Actions entry "Cache" opens the Edit Macro dialog instead of inserting the macro at once with an area to type in, like the Quick Action of html and async, see I3.
I2 zero-configOKsubmitting the Edit Macro dialog with the default values keeps it open with no message, the generic behavior, since the content is mandatory. A cache with an id and an empty content, {{cache id="x"}}{{/cache}} , renders nothing in view mode and shows the visible "macro:cache" placeholder in the editor, as html does. {{cache/}} written in the source, with no content and no id, renders "Failed to execute the [cache] macro. Cause: [Null keys are not supported!]", a raw message, kept as a bug outside the criteria since the dialog does not insert an empty content.
I3 instantKO"/cache" then Enter opens the Edit Macro dialog with an empty Content text area. The macro is only inserted after typing the content and submitting, unlike warning, which is inserted at once with its content area.
I4 cursorKOafter submitting the dialog the macro widget is selected and the cursor is not in the content: typing "TYPED" after inserting the macro with the content "Probe content" changes nothing, the page stays {{cache}}Probe content{{/cache}} , and the content can only be changed through the dialog, see E6.
I5 focusN/A
E1 wysiwygOKin the editor the macro shows its rendered content, "content to cache here..." for the audit example, in a widget whose generic "macro:cache" label is hidden, and the status bar shows macro:cache. The output is the content the user typed, as for html, so there is nothing else to replace.
E2 errorsKOthe invalid values of the number parameters are not handled. maxEntries with "abc", "-3", "0" or "2.5" renders "Failed to execute the [cache] macro. Cause: [ISPN000424: Memory eviction is enabled, please specify a maximum size or count greater than zero]", the same message as the first example of the documentation, which does not name the parameter. timeToLive with "abc", "-3" or "0" is accepted silently and the content renders as for a valid value, since the source only stores the number. An id with a space, "my id", is accepted, which is valid for a key written as text. An unknown parameter is accepted, which is generic.
E3 nestingKOthe macro renders in a list item, a table cell and a box with no error, and a list, a table and a box as its content render in view mode. But its content can never be edited in place in these cases, only through the Edit Macro dialog, see E5 and E6, which is the same call as for its sibling async. The "True, False" of the box row of the probe is the editable area of the box, not the macro content: the macro is a non-editable widget in every case.
E4 inline-supportOKthe macro declares inline support and renders inside a sentence with no error, Before {{cache id="e4x"}}inline text{{/cache}} after. gives "Before inline text after.".
E5 emptyKOminor: an empty macro, {{cache id="x"}}{{/cache}} , shows a visible "macro:cache" placeholder that one click selects but that never receives the cursor. With a content, the editor shows the output in a widget that is not editable either, see E6.
E6 inplaceKOthe content is never edited in place, not even right after the insertion, see I4: the editor shows the rendered content, and changing it needs the Edit Macro dialog, where it is a plain text area in the syntax of the page. A content with bold text and a list, submitted unchanged, is saved unchanged, so the dialog does not corrupt it.

Parameters

ParameterC1 clarityC2 mandatoryC3 defaultsC4 input-assistanceC5 groupsC6 orderC7 alternativesC8 advancedC9 technicalC13 constraintsNotes
$contentOKOKN/AOKN/AOKN/AN/AN/AN/A

C1: "Content" with "The content to cache." says what to type.

C2: mandatory, since an empty cache macro renders nothing, see I2.

C4: a plain text area in the Edit Macro dialog, counted under E6.

idKOOKOKOKOKOKOKOKOKOK

C1, minor: "Id" with "A unique id under which the content is cached." says what the value is, which is enough for a developer hook. It does not say that an empty id uses the content itself as the key, which the documentation does and the documentation also warns that the content does not guarantee unicity. Nor does it say that the id is read as wiki syntax and then rendered as plain text, so that a script macro can generate it, which is why examples 3, 4 and 6 of the documentation escape the macro, id="~{~{velocity~}~}$myid~{~{/velocity~}~}" : the escaping of the macro is the part users get wrong. In French and German the name is the ID in English too.

C3: empty. The default of the documentation, the content itself, is computed from the content and cannot be preselected, and the first example of the documentation sets an id, so the empty field does not hide a value that users would otherwise keep.

C8: every example of the documentation sets an id, so it stays visible.

maxEntriesOKOKOKKOOKOKOKKOOKOK

C1: "MaxEntries" is the ID title-cased in the dialog, and the description "The maximum number of entries in the cache (Least Recently Used entries are ejected)." explains it, which is enough for a developer macro. The name is the ID in English in the translations, in French too.

C3: 1000, the default of the macro, which is the usual value.

C4: a text field for a number, where a number input would only accept numbers. The values "abc", "-3" and "0" reach the macro and end with the error of E2.

C8: no example of the documentation sets it, and the cache it sizes is shared by every call with the same time to live and the same size, so it is a rare tuning, shown with the main options instead of as an advanced parameter.

C9: realistic use, for a macro that caches many different contents, so it stays visible.

timeToLiveOKOKOKKOOKOKOKOKOKOK

C1: "TimeToLive" is the ID title-cased in the dialog, and "The number of seconds to cache the content." gives the unit, which is enough for a developer macro.

C3: 300, the default of the macro, 5 minutes, which is the usual value.

C4: a text field for a number, where a number input would only accept numbers. The values "abc", "-3" and "0" are accepted silently, see E2.

C6: after maxEntries, though examples 5 and 6 of the documentation set it and none sets maxEntries. With three visible fields, none is hard to reach.

KOs and tickets

Every KO needs a ticket covering it, see Report the KOs. One ticket can cover several KOs. Known issues filed for this macro are suggested in italics: link them as existing tickets when they cover the KO.

KOCriterionExisting ticketsNew tickets
D2D2 summaryXWIKI-25479
L2L2 doc-parametersXINFRA-525
L3L3 doc-exampleXINFRA-526
I1I1 patternXWIKI-25563
I3I3 instantXWIKI-25563
I4I4 cursorXWIKI-25569
E2E2 errorsXWIKI-25182 (partial)XCOMMONS-3847 (partial), XRENDERING-823 (partial), XWIKI-25582 (partial)
E3E3 nestingCKEDITOR-248 (partial), XWIKI-19954 (partial), XWIKI-23309 (partial)XWIKI-25567 (partial)
E5E5 emptyXWIKI-25567
E6E6 inplaceXWIKI-25443 (partial), XWIKI-25567
C1:idC1 clarity, idXWIKI-25479
C4:maxEntriesC4 input-assistance, maxEntriesXWIKI-25182
C8:maxEntriesC8 advanced, maxEntriesXWIKI-25480
C4:timeToLiveC4 input-assistance, timeToLiveXWIKI-25182
Success

Every KO is covered by a ticket.

Tickets

TicketOriginKOs coveredKOs partly covered
XWIKI-25182ExistingC4:maxEntries C4:timeToLiveE2
XCOMMONS-3847NewE2
XRENDERING-823NewE2
XWIKI-25443NewE6
XWIKI-25479NewC1:id D2
XWIKI-25480NewC8:maxEntries
XINFRA-525NewL2
XINFRA-526NewL3
CKEDITOR-248ExistingE3
XWIKI-19954ExistingE3
XWIKI-23309ExistingE3
XWIKI-25563NewI1 I3
XWIKI-25567NewE6 E5E3
XWIKI-25569NewI4
XWIKI-25582NewE2

Known issues of this macro

No known issue is specific to this macro.
68 more known issues affect every macro: see the Known issues.

Get Connected