Skip to content

Admin Cache Actions ​

Superadmin-only purge/warm controls for routes with admin_cache_actions: true.

Enabling ​

php
'PackageCountry' => [
    'manual_purge' => true,
    'admin_cache_actions' => true,
    'purge' => ['presentationItem' => true],
],

Add ResourceCacheActionsTrait to the route repository. BaseController already includes ManageResourceCache.

Endpoints ​

MethodPathScopeAction
POST{route}/cache/purge/{id}recordPurge selected types
POST{route}/cache/warm/{id}recordRefresh (skip invalidation)
POST{route}/cache/purge-allindexFlush route tags
POST{route}/cache/warm-allindexQueue WarmModuleRouteCachesJob

Request body:

json
{ "types": ["presentationItem"] }

or { "types": "all" }.

Response:

json
{ "queued": true, "message": "...", "types": ["presentationItem"] }

UI actions ​

ResourceCacheActionsTrait registers form buttons (per record) and table toolbar buttons (route-wide), following the same pattern as RemoteApiSourceTrait:

  • Clear cache / Refresh cache on the edit form
  • Clear all cache / Refresh all cache on the index (with confirmation modal)

Buttons appear only when cache is enabled, admin_cache_actions is true, and the user is superadmin.

Artisan parity ​

bash
php artisan modularous:cache:clear BusinessPackage PackageCountry --presentationItems
php artisan modularous:cache:warm BusinessPackage PackageCountry --presentationItems