Magento 2 Adminhtml Cache Eviction Module

Magento 2 cache invalidation links added inline to the admin notification bar — Refresh Invalidated and Flush Cache in one click. ACL-gated, CSP-safe.

The default Magento 2 admin notification after a cache invalidation event leads to two clicks and a full page load before anything gets flushed. This module eliminates the detour by appending Refresh Invalidated Caches, Flush Magento Cache, and Flush Cache Storage links directly into the yellow notification bar that appears after saving any configuration value or other invalidating action. Best fit for teams that update system configuration regularly and want to act without leaving the current admin page.

<p class="brocode-impact-callout">Typical impact: cache cleared in one click from any admin page instead of two clicks and a full page load to Cache Management.</p>

<div class="brocode-cta-bar"><a class="wp-block-button__link wp-element-button" href="https://github.com/brosenberger/module-adminhtml-cache-eviction" rel="nofollow noopener" target="_blank" data-event="module_github_click">View on GitHub</a><a class="wp-block-button__link wp-element-button is-secondary" href="#brocode-inquiry" data-event="module_inquiry_click">Ask a question</a></div>

Who For

Who for this module: admins who interact with system configuration regularly and find the two-step navigation to Cache Management a friction point.

  • Store administrators who adjust tax rules, shipping settings, or payment provider config and get the cache invalidation notification on every save.
  • Developers iterating on module configuration during local or staging work — one-click flush prevents stale values from obscuring in-progress changes.
  • Support engineers validating a config fix from the admin panel, where navigating to Cache Management and back extends the workflow by 20-30 seconds per cycle.
  • Teams with strict ACL roles — each link is gated by the same permission the corresponding core Cache Management action requires, so restricted users only see what they can do.

Who Skip

Who skip this module: teams where admin cache friction is not a meaningful workflow cost.

  • Stores where admin configuration saves happen rarely and the two-step navigation to Cache Management is acceptable.
  • Teams that flush via bin/magento cache:flush from the CLI as their primary workflow and rarely interact with the notification bar.
  • Automated deployment pipelines that handle Magento 2 cache invalidation post-deploy without admin interaction.

How it works

The module registers an afterGetText plugin on Magento\AdminNotification\Model\System\Message\CacheOutdated — the class that produces the yellow notification text. The plugin appends plain <a href> links: URLs are generated via UrlInterface, ACL access checked via AuthorizationInterface, output escaped via Escaper. No JavaScript, no event listeners, no inline handlers.

Three links are conditionally appended based on the current admin user’s ACL:

LinkActionACL resource
Refresh Invalidated CachesCleans only the currently-invalidated types via a dedicated controllerMagento_Backend::refresh_cache_type
Flush Magento CacheDelegates to core adminhtml/cache/flushSystemMagento_Backend::flush_magento_cache
Flush Cache StorageDelegates to core adminhtml/cache/flushAllMagento_Backend::flush_cache_storage

The Refresh Invalidated Caches link targets a dedicated GET controller that reads the live invalidated type list with TypeListInterface::getInvalidated() and cleans only those types, then redirects back to the referring page. No manual type selection. The plugin is scoped to etc/adminhtml/di.xml and is never loaded for frontend, REST, GraphQL, or CLI requests.

Before and after

Before

  • Save a value in Stores → Configuration.
  • Read: "One or more of the Cache Types are invalidated: config, full_page. Please go to Cache Management and refresh cache types."
  • Navigate to System → Cache Management.
  • Select the invalidated types or click Flush Magento Cache.
  • Navigate back to the page you were editing.

After

  • Save a value.
  • Read: "… Quick actions: Refresh Invalidated Caches | Flush Magento Cache | Flush Cache Storage"
  • Click Refresh Invalidated Caches.
  • The invalidated types are cleaned. You land back on the same page with a success message.

Installation

composer require brocode/module-adminhtml-cache-eviction
bin/magento module:enable BroCode_AdminhtmlCacheEviction
bin/magento setup:upgrade
bin/magento setup:di:compile
bin/magento cache:flush

Alternatively, place the module directory at app/code/BroCode/AdminhtmlCacheEviction and run the same commands without the composer require step. No database schema changes.

Compatibility

  • PHP 8.1, 8.2, 8.3, 8.4
  • Magento 2.4.x — any release shipping magento/module-admin-notification
  • No known incompatibilities
  • No additional dependencies beyond magento/framework and magento/module-admin-notification

FAQ

Does this add any new ACL resources?

No. Each link reuses an existing Magento_Backend::* ACL resource that already controls the equivalent core action. If a user cannot perform the action in Cache Management, they cannot see the corresponding link in the notification bar.

Is it safe with Magento’s default Content Security Policy (CSP)?

Yes. All links are plain <a href> elements with server-generated URLs. No inline JavaScript, no javascript: URIs, no onclick attributes. Compatible with Magento 2.4.7+ CSP in both report-only and enforcement modes.

What happens if no cache types are invalidated when clicking "Refresh Invalidated Caches"?

The controller reads the live invalidated list at request time. If nothing is invalidated, it adds a notice ("No invalidated cache types found.") and redirects back without touching any currently-valid types.

Does the plugin affect frontend or API performance?

No. The plugin is declared in etc/adminhtml/di.xml and is never instantiated for frontend, REST, GraphQL, or CLI execution contexts.

Can I install it without Composer?

Yes. Place the module at app/code/BroCode/AdminhtmlCacheEviction, then run bin/magento module:enable BroCode_AdminhtmlCacheEviction and bin/magento setup:upgrade.

Related reading

Related Topics

Ask a module question or suggest improvements

Tell us your use case and the module context. Spam protection is handled by ALTCHA.




More Projects