Command
cache-clear (alias: cc)

Syntax
drush cc

There are often times when you need to clear the cache. This is always the first step to debugging an issue with your site. Cache can make your site run significantly faster once it's live, but during development it can also cause issues. One common reason to clear the cache is when you make an adjustment to your theme's CSS. If Drupal is caching the css files, your updates won't show up without clearing the cache. Let's take a look at that.

I'm going to modify the Bartik theme just as a demonstration. You don't ever want to modify a core file since your changes will be overwritten on the next update, but for the sake of this video, I'm going to do it anyway.

First, I'll enable CSS caching on the "Performance" page. (admin/config/development/performance) Then, I'll go to the homepage.

Now, I'll open up the "style.css" file in the Bartik theme folder, and change the h1 color to red. Then I'll go back to the homepage, and refresh the page. You'll notice that nothing has changed. The text "Welcome to Drush Site" is an h1, and according to our css file, should be red. It's not because the old css file is still in cache. Let's clear the cache to use our new css file.

  • drush cc

You'll see that you are given a list of cache options to choose from. In this case, you could choose "5" and clear the "css-js" cache, but I usually just clear all cache during development, and theres a shorter way to do that. Instead of just typing "drush cc", you can specify which cache to clear, and bypass the select list. (Your options are to the right of the colon.) I'll type "0" and push enter to cancel. Then clear all cache.

  • drush cc all

You'll see that all cache has been cleared, and when we go back to our homepage and refresh, you'll see that the change to our css file has been picked up.