I'm setting up an "editor" role for a D8 site. I noticed there's no "Flush all caches" in the Tools menu. I don't see any permission setting related to caches. How to enable cache clearing/cache rebuilding for non-admins?

  • 4
    On all projects I have worked so far there was always a custom route with a button to do that due to "administer site configuration" is just too powerful to give to editor or any non-superadmin role. – user21641 Apr 17 '17 at 19:44
  • 1
    Agreed that "admin site config" is too powerful of a permission. Have you seen any discussion on why clearing cache isn't broken out to it's own permission? – codesmith Apr 17 '17 at 20:39

To access this, they would need the administer site configuration permission.

From system.routing.yml:

  path: '/admin/config/development/performance'
    _form: 'Drupal\system\Form\PerformanceForm'
    _title: 'Performance'
    _permission: 'administer site configuration'
| improve this answer | |

I'd like to mind the following answer to a similar feature request on DO:

I kind of disagree with this because of the that shouldn't be necessary in the first place. With cache tags, any change that an editor can make should automatically invalidate all relevant caches. Anything else is a bug IMHO.

Nevertheless in real world sometimes it may be necessary to have other roles than the one with administer site configuration being able to rebuild caches.

Basically all you need to do is to build a trigger of some kind (button, route etc.) and let it fire drupal_flush_all_caches(). Have a look at the Devel module for a great example of this approach.

Since I was in need of this myself – which was why I came here in the first place – I finally built a small module and published it on DO. It adds its own permission and places a button on the admin toolbar from which every user with the new permission is now able to flush all caches:


Drupal flush cache permission module

| improve this answer | |
  • Hey, I installed your plugin but I do not see the rebuild cache access option in role settings... is installing the plugin and enable it is enough or I should take further actions? – DavSev Jan 6 '19 at 11:37
  • @DavSev – That's the machine name of the permission. The permission is called just "Rebuild Cache" and can be found under the "Rebuild Cache Access" section on example.com/admin/people/permissions, same as any other applicable user permission. – leymannx Jan 6 '19 at 16:16
  • Thank you for the fast response. I installed it in two d8 websites but I cant see the permission in /people/permissions – DavSev Jan 7 '19 at 8:30
  • @DavSev – Then please create an issue on drupal.org/project/issues/rebuild_cache_access and list the exact versions of everything you use (Drupal, Drush, OS, Browser etc.) and all steps to reproduce the issue (How exactly did you enable the module, Are you sure it's really enabled, did a cache flush help etc.). – leymannx Jan 7 '19 at 8:37

Go to People -> Permissions and then I hope you can find what to do

| improve this answer | |
  • This is for D7, not D8 – Tib Oct 4 '18 at 9:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.