Skip to the content
Documentation
Help Start
Reading in:
  • German: 9,059 of 9,059 pages
About the help in other languages
All help pages

View cache and cache blocks

How the content view cache and template cache blocks work - what is cached per page, which publish clears what (viewcache.ini), cache-block keys, expiry and subtree expiry, and how to debug stale output.

Download as PDF

Address: https://doc.exponential.earth/exphelp/viewer/help/creators/website-creators/view-cache-and-cache-blocks.md

On this page

View cache and cache blocks

This page is for website creators who template pages and need them both fast and current. Two caches do most of the work: the content view cache keeps the rendered main area of each page, and cache blocks keep parts of templates such as menus.

Contents

  1. The content view cache
  2. What a publish clears
  3. Cache blocks
  4. Keys, expiry and subtree expiry
  5. Debugging stale output

The content view cache

site.ini [ContentSettings]:

KeyShippedMeaning
ViewCachingenabledcache the output of content/view
CachedViewModesfull;sitemap;pdfthe view modes cached
CachedViewPreferences[]user preferences that change the output and become part of the key

A cached view is kept per node, view mode, language, siteaccess, user's roles and limitations, view parameters and layout. The pagelayout is not part of it: it runs every time, which is why it uses cache blocks.

What a publish clears

Publishing an object clears the cache of its own nodes, their parents, and related objects, as settings/viewcache.ini [ViewCacheSettings] says: ClearRelationTypes[] (common, reverse_common, reverse_embedded) decides which relations count; SmartCacheClear adds rules per class. A page that lists content from far away in the tree (a front page listing news) is not cleared automatically unless a rule says so; use subtree expiry in its cache blocks, or a smart cache clear rule.

Cache blocks

{cache-block keys=array( $module_result.uri, $current_user.contentobject_id )}
  ... expensive menu ...
{/cache-block}

The block's output is stored and reused while its keys match and it has not expired. Published content clears all template block caches by default, so a new folder appears in menus.

Keys, expiry and subtree expiry

ParameterMeaning
keysvalues the output depends on: the address, the user, the language
expiryseconds until the block expires (default two hours); 0 means never by time
ignore_content_expirythe block is not cleared by publishing
subtree_expirythe block is cleared only when something below this node is published

A front page news list:

{cache-block subtree_expiry='/News' expiry=0}
  {foreach fetch( 'content', 'list', hash( 'parent_node_id', 58, 'limit', 5, 'sort_by', array( 'published', false() ) ) ) as $item}
    {node_view_gui content_node=$item view='line'}
  {/foreach}
{/cache-block}

Never cache output that differs per user (a greeting, a basket count) without the user in the keys.

Debugging stale output

SymptomTry
A page shows old content after publish--clear-tag=content; then add a smart cache clear rule or subtree expiry
A menu shows an old folder--clear-id=template-block; check the block's keys
One user's data shown to anotherthe block lacks the user in its keys: fix now
Logged-in users see the same as visitorsCachedViewPreferences[] or keys lack what differs
Nothing changes after a template editthe template cache, then the content cache, then Velocity's cache

The debug bar shows which caches were used for a page (Exp debug bar).

Become an Exponential Partner

Partners share their information, provide funding, contribute back and develop the products with us, and that is how Exponential grows. A partner website and dashboard are planned for mid-2027: please become a partner today to speed up our growth rate and land new features faster.

Something wrong on this page? Report an error

Documentation license

This documentation is free documentation, licensed under the GNU Free Documentation License 1.3 or later.

Exponential Copyright © 1998-2026 Exponential Foundation and 7x