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; directoryCACHE_DIR.memory— per process only.redis— reserved; not implemented.CACHE_REDIS_URLis ignored for now.CACHE_ENABLED=0— always run the producer, never store.
Layers
| Prefix | What | Invalidated when |
|---|---|---|
page:html: | Full public HTML | Content, theme, menu, settings, CSS provider |
content: | Published items and alternates | Content save/delete |
theme:mods: | Customizer mods | Design/theme save |
menus: | Navigation | Menu edits |
css:provider: | Active framework assets | Provider activate/delete |
security-headers:config | Header policy | Security 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/statsand Tools → Object cache (hits, misses, hit rate, key count).- Site Health includes an object-cache check.
LOG_LEVEL=debuglogs 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.
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/*.