Cache Clearing and rebuilding methods for Drupal 8

Submitted by editor on Wed, 05/25/2016 - 09:55
Question

What are the methods for clearing or rebuilding Drupal 8 cache, using site url, drush SQL ... ?

Site URL

1. Go to Administration > Configuration > Development > Performance
 (/admin/config/development/performance)
2. Click on "Clear all caches"

Drush

drush cache-rebuild
OR
drush cr

Programmatically using PHP (From a drupal module) 

db_query("DELETE FROM {cache};");
 

By SQL / phpMyAdmin interface

Clear all tables that start with cache_ (CAUTION : Do not DELETE tables)
Ex:
TRUNCATE cache_config;
TRUNCATE cache_container;
TRUNCATE cache_data;
TRUNCATE cache_default;
TRUNCATE cache_discovery;
TRUNCATE cache_dynamic_page_cache;
TRUNCATE cache_entity;
TRUNCATE cache_menu;
TRUNCATE cache_render;
TRUNCATE cache_toolbar;

Run update.php

Running update.php (/update.php) is another way of clearing the cache.
If you cannot login or have no user 1 rights you will need to set in :
/sites/default/settings.php
$update_free_access = TRUE;  

Do not forget to set this back to FALSE afterwards.

...

Add new comment