Skip to content

Module Route Cache ​

Modularous caches admin panel data per module route — filter counts, paginated index queries, single records, form payloads, and formatted table rows. A relationship graph and relation tags keep dependent routes consistent when related models change.

This cache layer targets the admin CRUD stack (repositories and controllers). It does not automatically cache public CMS blade rendering; see CMS Public Pages for that gap and the recommended b2press strategy.

In This Section ​

PagePurpose
OverviewArchitecture, data flow, key format, trait map
Configurationmodularous.cache merge, app overrides, env vars
Cache Typescounts, index, record, formItem, formattedItem, response types
InvalidationCacheObserver, graph, dependencies, relation tags
Queue ObserverAsync invalidation/warmup jobs, env vars, workers
Manual PurgePer-route manual purge config
Admin Cache ActionsSuperadmin purge/warm UI + API
WarmupwarmupByModel, artisan warm commands
Per-Module SetupHasCaching + config checklist
CMS Public PagesAdmin cache vs public CMS; b2press presentation + full-page plan
SWRStale-while-revalidate and warm jobs
URL Stale ResilienceFile-primary URL cache
Webhook RevalidateHMAC webhook for external purge/warm
Console CommandsLinks to guide/console/cache/ command reference

Quick Start ​

bash
# 1. Ensure Redis is available (default driver)
# MODULAROUS_RESOURCE_CACHE_ENABLED=true
# MODULAROUS_RESOURCE_CACHE_DRIVER=redis

# 2. Enable caching for a module in config/modularous.php (or modularity.php)
# See Configuration and Per-Module Setup pages

# 3. Add HasCaching to the entity model
# use Unusualify\Modularous\Entities\Traits\Core\HasCaching;

# 4. Rebuild the relationship graph after enabling new modules
php artisan modularous:cache:graph rebuild

# 5. Pre-warm caches (optional, recommended after deploy)
php artisan modularous:cache:warm PressRelease PressRelease --counts --formattedItems

When to Use ​

Enable module-route cache when:

  • Admin index pages or filter badges are slow under production data volume
  • Form edit payloads (formItem) or table row formatting (formattedItem) are expensive to build
  • Related models (payments, packages, companies) should invalidate dependent admin routes automatically

Skip or narrow cache types when data changes every few seconds and stale UI is unacceptable — use shorter TTLs or disable specific types per route instead of turning off the whole system.