Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member

Controlling cache and cron

From: Simplified Drupal Sites with Drush

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.

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.

Show transcript

This video is part of

Image for Simplified Drupal Sites with Drush
Simplified Drupal Sites with Drush

18 video lessons · 4142 viewers

Jon Peck
Author

 

Start learning today

Get unlimited access to all courses for just $25/month.

Become a member
Sometimes @lynda teaches me how to use a program and sometimes Lynda.com changes my life forever. @JosefShutter
@lynda lynda.com is an absolute life saver when it comes to learning todays software. Definitely recommend it! #higherlearning @Michael_Caraway
@lynda The best thing online! Your database of courses is great! To the mark and very helpful. Thanks! @ru22more
Got to create something yesterday I never thought I could do. #thanks @lynda @Ngventurella
I really do love @lynda as a learning platform. Never stop learning and developing, it’s probably our greatest gift as a species! @soundslikedavid
@lynda just subscribed to lynda.com all I can say its brilliant join now trust me @ButchSamurai
@lynda is an awesome resource. The membership is priceless if you take advantage of it. @diabetic_techie
One of the best decision I made this year. Buy a 1yr subscription to @lynda @cybercaptive
guys lynda.com (@lynda) is the best. So far I’ve learned Java, principles of OO programming, and now learning about MS project @lucasmitchell
Signed back up to @lynda dot com. I’ve missed it!! Proper geeking out right now! #timetolearn #geek @JayGodbold
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.

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?

Become a member to like this course.

Join today and get unlimited access to the entire library of video courses.

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 preferencesfrom 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.

Are you sure you want to delete this note?

No

Your file was successfully uploaded.

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.