Fazeela Abu Zohra
Fazeela Abu Zohra

Reputation: 631

Disable caching for a node type in Drupal 7

I would like to disable caching for nodes of a particular node type 'event'. I did it using hook_boot() and set the page cache as FALSE. I have cleared cache, then in one node of type event, I have made a change, but the anonymous user cannot see the page. It is just giving the copy of its cache.

function hook_boot() {
if ($_GET['q'] != '') {
  $url = $_GET['q'];
  $nid = substr($url, strrpos($url, '-') + 1);
  $type = db_select('node','n')
   ->fields('n', array('type'))
   ->condition('n.nid', $nid)
   ->execute()
   ->fetchAssoc();
   if ($type == 'event') {
     drupal_page_is_cacheable(FALSE);
   }
  }
}

Upvotes: 0

Views: 314

Answers (1)

MilanG
MilanG

Reputation: 7124

Maybe this module can help you? https://www.drupal.org/project/cacheexclude

Upvotes: 1

Related Questions