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

Caching layers for engineers

Every cache between a visitor and the database of an Exponential site, seen by an engineer - what each layer stores, what it is keyed on, whether it ships on, who it serves, which servers share it, and the correctness…

Download as PDF

Address: https://doc.exponential.earth/exphelp/viewer/help/software-engineers/caching-layers-for-engineers.md

On this page

Caching layers for engineers

This page is for engineers who reason about performance and correctness together. Exponential has many caches; most performance work is choosing which to switch on, and most "stale page" bugs are one of them answering when it should not. The operator's view of the same layers is Caching layers, and the administration page is described in Caches.

Contents

  1. The layers in order
  2. What each layer is keyed on
  3. Shared or per node
  4. Correctness risks
  5. Choosing what to switch on

The layers in order

From the visitor down to the database:

#LayerShipsServesSource
1Browser cache of static filesVelocity: StaticMaxAge one yeareveryoneHTTP caching
2Browser cache of pagesoff ([HTTPHeaderSettings])anonymous visitors, when switched onHTTP caching
3CDN or caching proxynot part of Exponentialas configuredExponential sends no purges
4Velocity response cacheon under Velocity (velocity.ini [CacheSettings] Enabled=enabled)anonymous visitorsVelocity response cache
5Role-aware HTTP cacheoff (httpcache.ini)anonymous and signed-in, per permission contextHTTP cache
6Static cacheoffanonymous visitors, as filesStatic cache defaults
7Content view cacheon ([ContentSettings] ViewCaching=enabled)every visitorCaches
8Template block cacheon ([TemplateSettings] TemplateCache=enabled)every visitorThe template engine and the design chain
9Compiled templates, INI and override cachesonevery requestCaches
10Redis or Valkey for views, blocks, INIonly with sevenx_valkey_cacheevery requestsevenx_valkey_cache
11SQL query cacheoff (querycache.ini Mode=off)every request it can answerThe SQL query cache
12OPcache, APCuper PHP processevery requestyour PHP configuration

The Velocity response cache exists only under the qbix engine: FrankenPHP has none yet, and PHP-FPM behind Apache or nginx has none of its own (Application servers).

What each layer is keyed on

LayerKey (in short)Invalidated by
Velocity response cachethe request of an anonymous visitor; lifetime [CacheSettings] DefaultTtl (30 seconds shipped) unless the page's Cache-Control says otherwiselifetime, ./console exp:velocity cache clear --apply
Role-aware HTTP cachethe content view and the permission context (anonymous, a shared role context, or private)content change purges (ContentChangePurges=all by default), --clear-id=exphttpcache
Content view cachethe node, the view and its parameters, and the user's access contexteZContentCacheManager on publish, --clear-tag=content
Template block cachethe keys written in {cache-block}, and its expiryexpiry, --clear-id=template-block
INI cachethe files of the cascade for a siteaccess (and environment)--clear-tag=ini
SQL query cachethe SELECT statementa write to one of the tables it read

Shared or per node

The caches in var/ are files written through the cluster file handler, so the same code can share them on clustered storage. Velocity's response cache and the in-memory state of its workers are per server process; OPcache and APCu are per PHP process. With several web nodes, decide for each layer whether it is shared, purged on every node, or allowed to expire (Scaling and clustering).

Correctness risks

  • Clearing before reloading. A page rendered by the old code between a cache clear and the reload of PHP-FPM or Velocity is cached again; clear page caches last (Deploying a change).
  • Writes from outside. A restore or a SQL client write bypasses the SQL query cache's invalidation; clear it afterwards.
  • Cache blocks without the right keys. A {cache-block} that does not key on what changes the output serves one user's or one page's fragment to another.
  • Velocity keeps settings in memory. After an INI change, clearing the INI cache is not enough under Velocity; restart it.
  • Static cache. With it on, every publish regenerated every affected page over HTTP inside the editor's request; the project ships it off and recommends leaving it off.

Choosing what to switch on

  1. Keep the shipped defaults: view cache, template blocks, compiled templates, INI cache.
  2. For anonymous traffic, under Velocity, the response cache gives the largest gain per change.
  3. For signed-in traffic, the role-aware HTTP cache keeps whole views per permission context.
  4. For pages that cannot be stored whole (the administration, private contexts, scripts), the SQL query cache.
  5. For several web nodes, consider Redis or Valkey for views, blocks and INI.

Measure each step (Performance measurement and benchmarks).

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