Before we get into details on why you should rush to clear your Drupal cache whenever you're dealing with a “White Screen of Death”, how about exercising your imagination a bit?
Scenario no. 1:
“You're a visitor, accessing one specific page of a Drupal website, then switching to another one, then... all of a sudden... the web page you will have just landed on instantly turns all white! All content disappears!”
Scenario no. 2:
“You're a Drupal web developer and you've just given your theme a “routine” update. Or maybe you've just finished developing a custom module. Everything seems to be working perfectly fine on your Drupal site when... tragedy... meaning WSOD... strikes and leaves you “defenseless”: staring at the big white nothing!”
Does any of these 2 scenarios bring back unpleasant memories?
Well, in today's post we're ready to help you put together your own “emergency kit”! The one including all possible solutions to apply whenever WSOD strikes again, focusing, of course, on the “clear your Drupal cache” one. Keep reading:
1. But How Does Drupal's Cache System Work After All?
Drupal's caching is a key performance-booster!
What it does is saving and storing copies of the requested content on a Drupal site's page, so that when the next visitor accesses the same web page link, it will automatically display the stored content. A great way of saving your server's resources.
Now, with all the “hard work” that its caching tables need to do (storing and then delivering the stored content, the menu links, the scrips), now and then “accidents” happen and they stop delivering content. Therefore: WSOD happens!
2. "White Screen of Death": What's Causing it?
Maybe the term “causes” is not the most appropriate one. Let's replace it with “instances”: instances when WSOD occurs.
Here are a few:
- after you've updated the theme on your Drupal site
- after you've updated a Drupal module
- after you've run your updates on Drupal core itself
- while you're developing a custom module for your (or your client's) site
- after you've moved your Drupal site to another server
What does this mean?
Well, it means that since we have a “bundle” of instances when this terribly frustrating error occurs, we also have a “bundle” of possible solutions to rely on for getting it fixed.
And, speaking of them, our team of Drupal web developers', here at OPTASY, favorite one if the “clear your Drupal cache” emergency solution!
3. Which Are The Other Ways to Fix a WSOD Error?
As already stated: clearing your Drupal cache is not THE one and only way to resolve the “big nothing” problem on your Drupal site.
Here are just some of the other methods you could include in your “emergency kit”, whenever you're dealing with a “White Screen of Death”:
- check your Watchdog tables
- check your error log files
- recreate your permissions
- restart your web server
- uninstall the problematic modules
- enable error reporting (although, these are cases when a WSOD can lock down your site completely, caching the very “culprit” code itself, the one that might be causing the “white chaos”)
And there are many other possible solutions to the “white nothingness” error. We've just listed some of them.
Take them all into account and make sure you have this “emergency list” at hand when... the inevitable occurs!
Needless to add that, based on our own experience as Drupal developers, we recommend you, as a way to fix your future WSOD errors, to clear your Drupal cache.
4. Which Are the Main “Clear Your Drupal Cache” Methods?
4.1 Use Drush
Rely on Drush command-line interface for a quick fix of your “White Screen of Death” error!
Here are the Drush commands to use to clear your Drupal cache (depending on the Drupal version that you're using):
In Drupal 7:
- drush cc or drush cache-clear: for selecting which cache to clear
- drush cc all or drush cache-clear all: for clearing all the caches at once
In Drupal 8:
- drush cr or drush cache-rebuild: for rebuilding your website and clearing all its caches
4.2 Use the Database
You could also clear your Drupal cache manually, by emptying all the cache tables stored in your database.
Of course, it goes without saying that you should go for this method only if you're confident enough (leaving no room for human error in the equation) to handle those database tables: if you know what you're doing!
This is a two-step solution, in fact:
- use phpMyAdmin (or maybe you prefer another database administrative tool instead) to access your site's database.
- manually empty the “cache” labeled (you'll see the “cache_” prefix there) tables from your database, without deleting them (do keep this “tiny detail” in mind!)
Note: Remember to make an update of your website before you go ahead manipulating its database!
4.3 Use the Performance Page
And the third “clear your Drupal cache” method on our list is the one implying the Performance Page.
Just go to admin/config/development/performance and click on the “Clear all caches” button. Cache clearing made simple!
It looks like we've reached the end of today's post on how to clear your Drupal cache and why you should start seeing it as a handy solution to your WSOD errors!
And yet, allow us to give you one last piece of advice: make a habit of testing your updates first instead of running them directly on your live website!
It's probably one of the simplest ways of keeping the “White Nothingness” at bay!
We do Drupal development
Go to our Drupal page!