Skip to content

Exponential CMS

The HTTP cache

Cache headers for anonymous visitors, and the role-aware cache that serves whole pages before the kernel starts.

Exponential has two HTTP caching features. Both are off by default and change nothing until you switch them on.

1. Cache headers for anonymous visitors

By default every page says no-cache. To let browsers, proxies and content delivery networks keep pages for anonymous visitors, set [HTTPHeaderSettings] in settings/override/site.ini.append.php:

[HTTPHeaderSettings]
CustomHeader=enabled
OnlyForAnonymous=enabled
OnlyForContent=enabled
HeaderList[]
HeaderList[]=Cache-Control
HeaderList[]=Expires
Cache-Control[]
Cache-Control[/]=public, max-age=60
Expires[]
Expires[/]=60

OnlyForAnonymous is what makes this safe: a signed-in editor always receives the original no-cache headers, so a personal page never reaches a shared cache. The trade is staleness: an anonymous visitor may see a page up to max-age seconds old. Clear the INI cache afterwards, then check both directions with curl -sI, once anonymous and once with a signed-in session cookie.

Velocity sends static files with a long lifetime: velocity.ini [ServerSettings] StaticMaxAge, one year by default. Lower it while you work on a stylesheet.

2. The role-aware HTTP cache

This cache keeps whole rendered content pages per permission context and serves them before the kernel starts: one context for anonymous visitors, one shared by every user with the same roles and limitations, and a private one where a read policy depends on who the user is.

  1. Switch it on in settings/override/httpcache.ini.append.php: [HttpCacheSettings] Enabled=enabled.
  2. Under Apache, PHP-FPM or FrankenPHP, include kernel/private/classes/httpcache/ezphttpcacheearlyexit.php from config.php. Under Velocity the server process answers by itself.
  3. Keep sessions in files every server can read: the early exit finds the visitor from the session file named by the cookie.
  4. Restart Velocity with exp:velocity restart.

curl -sI https://www.example.com/ | grep -i x-exp-cache then shows HIT, STALE, MISS (reason) or BYPASS (reason).

Settings in httpcache.ini

  • CachedSiteAccesses[]: site by default.
  • MaxAge: 3600 seconds, the longest life of a page even when nothing purges it.
  • StaleWhileRevalidate: 60 seconds, an expired page is served while one request renders it again.
  • ContentChangePurges: all (any content change purges every page) or tags (only pages that show what changed).
  • QueryStringParameters[]: pages requested with any other query parameter are not cached.
  • MaxBodySize: 2 MB; larger pages are not stored.
  • SharedStateDir: where purges are shared between several web servers.

The visitor's form token is taken out of a stored page and the visitor's own put back on every hit. Neither feature is the Velocity response cache or the static cache; see Velocity response cache.

Last updated 11/26/2026. Something missing or wrong? Write to info@se7enx.com.