JustFlows

Caching

jf-cache drivers, what is cached, headers, stats, clear, and the plugin cache API.

8 min read

Justflows ships jf-cache so hot paths skip the database. Redis is not required. Configure in .env or Tools → Performance suite. Full narrative: docs/CACHE.md in the platform repo.

Drivers

  • filesystem (default) — survives process restart; directory CACHE_DIR.
  • memory — per process only.
  • redis — reserved; not implemented. CACHE_REDIS_URL is ignored for now.
  • CACHE_ENABLED=0 — always run the producer, never store.

Layers

PrefixWhatInvalidated when
page:html:Full public HTMLContent, theme, menu, settings, CSS provider
content:Published items and alternatesContent save/delete
theme:mods:Customizer modsDesign/theme save
menus:NavigationMenu edits
css:provider:Active framework assetsProvider activate/delete
security-headers:configHeader policySecurity save (short TTL)

Preview (?preview) and logged-in editors bypass page cache. Responses may include X-Jf-Cache: hits=… and X-Jf-Page-Cache: HIT|MISS|BYPASS.

Clear and inspect

  • Tools → Clear cache now (no restart).
  • POST /api/cache/clear (administrator).
  • justflows cache clear.
  • GET /api/cache/stats and Tools → Object cache (hits, misses, hit rate, key count).
  • Site Health includes an object-cache check.
  • LOG_LEVEL=debug logs HIT/MISS lines.

API for core and plugins

Preferred: remember(key, ttlSeconds, fn) — read-through with in-flight deduplication. Also get, set, delete, invalidate(prefix), clear. Plugins only see plugin:{id}: keys via ctx.cache.

ts
const menu = await ctx.cache.remember("primary", 300, () => loadMenu());

Selective revalidate: CACHE_REVALIDATE_ENABLED and CACHE_REVALIDATE_OBJECTS (pages, content, menus, theme, cssProviders, site). Action cache.revalidated fires when it completes. Related admin routes also exist under /api/performance/*.