Skip to main content
CafeWebmaster

Main navigation

  • Tools
    • MD5 converter
    • SHA1 converter
    • Base64 encode
    • Base64 decode
    • HTML entities encode
    • HTML entities decode
    • Raw url encode
    • Raw url decode
    • UTF8 encode
    • UTF8 decode
    • Unix Time to Human Date converter
    • Remove duplicate lines
    • Sort text lines
    • Backwards - Mirrored Text
    • PiRaTe tExT
    • Your IP Address & Hostname
  • Forums
  • Free PHP Scripts
    • Image watermark with PHP
    • Page generation time with PHP
  • CSS
    • CSS hidden left menu
    • CSS horizontal menu
  • Free Fonts
  • Image Editors
  • Tutorials
    • Check password strength / safety with PHP and Regex
    • Cómo hacer que su sitio web popular!
    • How2 make a website popular
    • How2 secure your website
    • Kennwort Sicherheit mit PHP und Regex Prüfen
    • Page generation time and http-referrers with php
    • Redirect webpages with HTML, PHP, .htaccess, Java+Script, CGI-Perl, ASP.NET and ColdFusion
  • New
User account menu
  • Log in

Breadcrumb

  1. Home
  2. Forums
  3. General discussion

Empty Drupal's cache : 4 methods !

By Anonymous (not verified), 12 September, 2023
Forums
General discussion

Emptying the cache in Drupal is an important maintenance task, especially when you've made changes that are not yet visible on the site. Clearing the cache ensures that the changes take effect immediately and helps in debugging issues. 

1. Via Admin UI

  • Log in to Admin Account
  • Go to Administration > Configuration > Development > Performance.
  • Click the Clear all caches button at the top of the page.
Image
 drupal-clear-cache


2. Using Drush


If you have Drush installed, cache clearing becomes a simple command-line task.

  • Open Terminal
  • Navigate to Drupal Root: Use cd to navigate to the Drupal root directory.
  • Execute the following Drush command:

      drush cache:rebuild   

    or use the shorter version

       drush cr   


3. Custom PHP Code


Insert the following PHP code snippet:
 

   \Drupal::service('page_cache_kill_switch')->trigger();   

or
   drupal_flush_all_caches();   


 


4. Via Database


This is the least recommended method and should only be used when other methods are not feasible.

  • Access Database: Use a database management tool like phpMyAdmin.
  • Find tables that start with cache_.
  • Empty Tables: Select these tables and empty them.


Clearing cache too often may affect performance. It's advisable to do it only when necessary.

  • Log in to post comments
CafeWebmaster.com(CW) is a free online community for webdevelopers and beginners. Anybody can share their code, articles, tips, tutorials, code-examples or other webdesign related material on the site. Newbies can submit their questions and reply to existing questions. CW does not guarantee or warrant reliability of code, data and information published on the site. Use the site on your own risk. The site takes no responsibility of direct or indirect loss or any kind of harm to its users. The site also doesn't take responsibility of infected files or source code with any kind of infection or viruses, worms, spywares, malwares, trojan horses. CW reserves the right to edit, move, or delete any of content for any reason.