I'm working with a node type that has several custom fields. The values of these fields need to refresh on each page load, but because of Drupal's caching feature, they don't. What is the best way (simplest way) to stop this content type from caching?
2 Answers
See if http://drupal.org/project/cacheexclude can do it for you. If not you need to create a module that will implement hook_init. Inside of that hook you need to load the node from arg() from there see if the node is of a certian type; if it is disable the page cache.
<?php
// Get the current active node object if present.
$node = menu_get_object();
if (!empty($node) && !empty($node->type) && $node->type == 'page') {
drupal_page_is_cacheable(FALSE);
}
?>
For Drupal 8:
// Mark this page as being uncacheable.
\Drupal::service('page_cache_kill_switch')->trigger();