Controlling cache and cron
Video: Controlling cache and cronDrupal 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.
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.
- 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
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.
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.