Simplified Drupal Sites with Drush
Illustration by John Hersey

Simplified Drupal Sites with Drush

with Jon Peck

Video: Controlling cache and cron

Drupal is like an engine, a complex system with many moving parts working in conjunction with one-another to deliver power. By opening the metaphorical hood and working directly with the engine, using the right tool, a properly equipped site administrator can quickly perform potentially cumbersome tasks with ease. This chapter will cover a number of tools and techniques useful for performing low-level operations on a Drupal site. Out of the box, Drupal provides a number of caching mechanisms to improve site performance and avoid heavy or repetitive tasks.

Start your free trial now, and begin learning software, business and creative skills—anytime, anywhere—with video instruction from recognized industry experts.

Start Your Free Trial Now
please wait ...
Watch the Online Video Course Simplified Drupal Sites with Drush
1h 22m Intermediate Dec 06, 2012

Viewers: in countries Watching now:

Manage your Drupal sites even more efficiently with Drush, the shell interface for managing and scripting Drupal site development. In this quick course, author Jon Peck describes what Drush is, how to install it, and how to use it effectively for everyday—and exceptional—tasks.

The course describes how to manage users, download and install modules and themes, archive and restore your entire site, and employ site variables for fast, full control over your Drupal sites. Plus, discover how to script an entire Drupal site installation with and without site profiles.

Topics include:
  • What is Drush?
  • Installing the prerequisite files
  • Installing Drush with PEAR, manually, and just for Windows
  • Installing Drupal sites
  • Managing themes
  • Controlling user access
  • Controlling cache and cron
  • Reading logs
  • Updating modules
Subjects:
Developer Web
Software:
Drupal Drush
Author:
Jon Peck

Controlling cache and cron

Drupal is like an engine, a complex system with many moving parts working in conjunction with one-another to deliver power. By opening the metaphorical hood and working directly with the engine, using the right tool, a properly equipped site administrator can quickly perform potentially cumbersome tasks with ease. This chapter will cover a number of tools and techniques useful for performing low-level operations on a Drupal site. Out of the box, Drupal provides a number of caching mechanisms to improve site performance and avoid heavy or repetitive tasks.

For example, both the menus and the blocks are extensively cached and Drupal gives precedence to these caches over configuration stored in code. This can present a problem when developing modules as code changes will not be immediately shown on a site. Additionally, when transferring a site between hosting environments, cache settings for file locations and paths can cause problems when attempting to access the transferred site without clearing the cache which tends to result in an incomplete or broken site.

Log back into the site: admin, admin. Drupal provides an interface for clearing all caches deep within the Admin menu. If you go to Configuration>Performance, you see a button, Clear all caches. It's time-consuming to wade through the menus to find this button and sometimes there's no need to clear every cache, only a certain cache such as the menu or aggregated and compressed CSS files. Drush provides a mechanism to handle these issues with the Cache Clear command aliased as cc, drush cc --help.

The Cache Clear command takes an optional argument, the name of the cache to clear. If the argument is omitted, Drush will give a choice of the available caches, type: drush cc, and press Enter without any arguments. All will do the same as clear all caches and often this is used as a magic bullet to fix strange caching issues. Do be cautious however, as this will degrade performance for the next few page views until the caches are regenerated. Press 1 to clear all caches. The same command can be executed by specifying "all" as the argument.

I use this often enough that it's practically muscle memory, drush cc all. The second cache to clear, drush, is specific to commands used by Drush. If new Drush functionality was installed in the module, but Drush does not recognize the command when accessed, clear the drush cache. I personally have not had to use the clear drush cache very often. Theme registry is useful when developing themes and adding a new template. The rest of the options are straightforward, the menu is the menu cache; css-js clears the aggregated in cache style sheets and JavaScript files; block clears the block cache, and so forth.

To explicitly clear one of these caches either use drush cc, press Enter and type the number of the selection, or give the machine name of the cache to clear such as: drush cc menu. Caches typically have an expiration date and therefore have a chronological context. With that in mind, caches are not the only time-based mechanism that executes in Drupal. A cron job is a time-based event that executes some regularly scheduled operation such as: checking site updates, indexing site content with the search module, importing site content from a third-party, and so forth.

In Drupal 6, cron execution needed to be set up manually or leverage the contributed module poormanscron, which triggered these time-based events after a regular page load from a visitor. poormanscron was included in Drupal 7 Core eliminating the need for additional configuration or module installation. However, regardless of the mechanism that triggers them, sometimes it's useful to manually execute these time-based events. The drush command cron, which has no alias, runs all cron hooks for every active module in a given site.

The drush cron command takes no arguments or options: drush cron. Upon completion, feedback is given. On the topic of feedback, the Drupal logging system contains a vast wealth of feedback and debugging information from various side events.

There are currently no FAQs about Simplified Drupal Sites with Drush.

 
Share a link to this course

What are exercise files?

Exercise files are the same files the author uses in the course. Save time by downloading the author's files instead of setting up your own files, and learn by following along with the instructor.

Can I take this course without the exercise files?

Yes! If you decide you would like the exercise files later, you can upgrade to a premium account any time.

Become a member Download sample files See plans and pricing

Please wait... please wait ...
Upgrade to get access to exercise files.

Exercise files video

How to use exercise files.

Learn by watching, listening, and doing, Exercise files are the same files the author uses in the course, so you can download them and follow along Premium memberships include access to all exercise files in the library.


Exercise files

Exercise files video

How to use exercise files.

For additional information on downloading and using exercise files, watch our instructional video or read the instructions in the FAQ .

This course includes free exercise files, so you can practice while you watch the course. To access all the exercise files in our library, become a Premium Member.

* Estimated file size

Are you sure you want to mark all the videos in this course as unwatched?

This will not affect your course history, your reports, or your certificates of completion for this course.


Mark all as unwatched Cancel

Congratulations

You have completed Simplified Drupal Sites with Drush.

Return to your organization's learning portal to continue training, or close this page.


OK
Become a member to add this course to a playlist

Join today and get unlimited access to the entire library of video courses—and create as many playlists as you like.

Get started

Already a member ?

Exercise files

Learn by watching, listening, and doing! Exercise files are the same files the author uses in the course, so you can download them and follow along. Exercise files are available with all Premium memberships. Learn more

Get started

Already a Premium member?

Exercise files video

How to use exercise files.

Ask a question

Thanks for contacting us.
You’ll hear from our Customer Service team within 24 hours.

Please enter the text shown below:

The classic layout automatically defaults to the latest Flash Player.

To choose a different player, hold the cursor over your name at the top right of any lynda.com page and choose Site preferences from the dropdown menu.

Continue to classic layout Stay on new layout
Exercise files

Access exercise files from a button right under the course name.

Mark videos as unwatched

Remove icons showing you already watched videos if you want to start over.

Control your viewing experience

Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.

Interactive transcripts

Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.

Learn more, save more. Upgrade today!

Get our Annual Premium Membership at our best savings yet.

Upgrade to our Annual Premium Membership today and get even more value from your lynda.com subscription:

“In a way, I feel like you are rooting for me. Like you are really invested in my experience, and want me to get as much out of these courses as possible this is the best place to start on your journey to learning new material.”— Nadine H.

Thanks for signing up.

We’ll send you a confirmation email shortly.


Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

Keep up with news, tips, and latest courses with emails from lynda.com.

Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

   
submit Lightbox submit clicked
Terms and conditions of use

We've updated our terms and conditions (now called terms of service).Go
Review and accept our updated terms of service.