You are here

function cacheexclude_init in CacheExclude 7.2

Same name and namespace in other branches
  1. 5.2 cacheexclude.module \cacheexclude_init()
  2. 6.2 cacheexclude.module \cacheexclude_init()

Implements hook_init().

File

./cacheexclude.module, line 60

Code

function cacheexclude_init() {
  $pages = trim(variable_get('cacheexclude_list', ''));

  // If the current page is one we want to exclude from the cache,
  // set the page caching to false temporarily.
  if (strlen($pages) && (drupal_match_path($_GET['q'], $pages) || drupal_match_path(drupal_get_path_alias($_GET['q']), $pages))) {
    drupal_page_is_cacheable(FALSE);
    return;
  }

  // Check if the current node type is one we want to exclude from the cache.
  if ($node = menu_get_object('node')) {
    $types = array_filter(variable_get('cacheexclude_node_types', array()));
    if (in_array($node->type, $types)) {
      drupal_page_is_cacheable(FALSE);
    }
  }
}