19th February 2010 - 3 minutes read time
It is sometimes necessary to turn off caching on certain pages on a Drupal site. This might be when trying to do something out of the ordinary, like write information to a file, or randomly generate a section of a template. The following code can be used to turn off caching just on the front page of the site.
function theme_preprocess(&$vars, $hook) {
if ($vars['is_front'] == true) {
$GLOBALS['conf']['cache'] = false;
}
}
Adding false to the cache item of the conf globals array at run time will turn off the cache. This is within an if statement that checks to see if the current page is the Drupal front page so it will only be used on the front page.