Drupal – Add clear cache link on menu

We can create a page which will clear the cache when it is loaded, and then add a new menu item linking to that page.

1. Create a new page with the following PHP code.

<?php
  drupal_flush_all_caches();
  drupal_set_message('cache flushed.');
?>


 

2. Make sure the body is set with PHP code input text format.
 

3. Add a new menu item.
 

So now whenever the user click the new menu item link, the Drupal cache will be cleared. And this approach also works in Drupal 7.

Done =)

Reference: A page to clear your cache

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.