Clearing Drupal's cache to recover from WSODs

Clearing Drupal's cache to recover from WSODs

Posted 04/01/2010 - 02:24 by State68

One of the most frustrating things that can happen when you're building a Drupal site is for the site to go blank - entirely blank, so whenever you load the site you're presented with the infamous White Screen of Death.

There are loads of tips on that page that will help you recover from a WSOD, but the three most common causes are:

  • Issues with PHP memory limits (there's some stuff about that here).
  • Some module or theme that hasn't quite enabled properly. I'll try and get round to writing a blog post about this soon :P.
  • Your site's cache table is all messed up.

In this post I'm going to look at the third situation. First, a little bit about why the caching table exists in the first place.

Every time Drupal loads a page it has to make hundreds of calls to its database. It has to load the data for the page itself, the menu links that are on that page, any content that's being displayed in blocks, and so on and so forth. Each of these calls to the database is "expensive": it takes up a lot of your server's resources, and takes a long time.

To get round these problems, the first time Drupal loads a specific page it copies some of the data it's had to load into the cache table. This means that the next time Drupal wants to load that page, it can go to the cache table rather than spinning all the way round the database a hundred times having to re-build the page from scratch. And better still, Drupal knows which pages are going to have changed, so the cache data will always be right.

Right, that is, until the cache table screws up and your site presents you with a blank page. The first thing to do is not to panic: it's really unlikely that any of the actual site data is going to have been lost; all that's happened is that the cached copy that Drupal has made has got messed up: so all you have to do is clear the cache, and Drupal will rebuild it automatically with a working set of data.

But how can you do this when your site is WSODing, and you can't get access to any of the usual ways you clear Drupal's cache via the UI? Well, you're gonna have to dive into the Drupal database and clear the cache table manually. Not as scary as it sounds.

It's likely that you're using PHPMyAdmin to access your site's database. If you're using something else then the general process outlined below still applies, but the specifics will be a little different.

  1. Log in to PHPMyAdmin
  2. In the left-hand column of the screen, click the database that is running your Drupal site
  3. The database's tables will be displayed in the left-hand column of the screen. Click the "cache" table
  4. The entries in the cache table will be listed in the main part of the screen. At the top of this part of the screen is a tab labelled "Empty": click it. A dialog box will pop up asking you if you really want to TRUNCATE (MySQLese for "empty") the table. Click OK
  5. Your cache table is now cleared. Go back to your Drupal site and try a few force-refreshes: Ctrl+Shift+R in Firefox. With a bit of luck, you should have your site back :)

As always, if this tutorial does or doesn't make sense then post a comment.

not found empty

sorry i didn't find empty label in phpmyadmin->cache table...what else i can do

Posted by Anonymous on Wed, 07/13/2011 - 14:51
Check out the image at

Check out the image at http://www.siteground.com/knox/tutorials/uploaded_images/images/phpmyadm... - can you see the "Empty" and "Drop" tabs in the top right of the image? Can you also see these in your phpmyadmin interface?

Posted by State68 on Fri, 07/15/2011 - 08:41
I had a WSOD moment!!

Thanks for the clear and precise posting. You really saved me a lot of frustration and a long Friday night fighting with "WSOD".

I am long time developer, but Drupal Newbie. It's a good product, but I've been stumped so many times with it. Each time there is a new issue and hours of googling. I had a situation where I had WSOD and if I copied a page.tpl.php into theme folder, then I get the screen with all div's drawn out.

I kept clearing cache after cache in Drupal, Devel module etc. Nobody else mentioned the cache table.

Thanks again. Keep up the good work!

Sam

Posted by Anonymous on Sat, 08/07/2010 - 05:26