I'm working on facebook like button for drupal 8. It's about to be done, but I've faced a trouble. Whenever I change the configuration of my module, I still need to clear all caches manually for the changes to take effect.

I'm adding the like button like this:

function fblikebutton_node_view(&$build, $node, $display, $type, $lang) {
  $build['fblikebutton'] = [
    '#theme' => 'fblikebutton',
    '#weight' => 100, 

Are there any ways to prevent all nodes from caching or to clear cache programmatically after configuration is updated? Or I should just change the way I add the button to the page?


It is not clear what exactly you are asking.

@Cottser's answer is correct for disabling the render cache during development but that is not something you want to do on a production site as the render caching critical for performance. Also, when disabling the render cache locally, make sure to always test changes on the same configuration as production to catch problems with it.

If the markup you are outputting is dynamic on something, then you can add that context to the cache key, see my answer in https://drupal.stackexchange.com/a/140777/31.

If it is about clearing the cache after the user changes settings, you can clear the node_view cache tag with Drupal::entityManager()->getViewBuilder('node')->resetCache(). If you want to clear the cache of a specific tag, you can pass the node ID to that method or you can use \Drupal\Core\Cache\Cache::invalidateTags($node->getCacheTags()).

Each thing that is rendered has one or multiple cache tags (inspect the X-Drupal-Cache-Tags header of a page response, I'm sure there will be development tools to better understand them in the future), by invalidating them, you can automatically clear all caches that contain them.


The node entity rendering is cached.

To disable the render cache, uncomment the following lines from the bottom of settings.php, copy sites/example.settings.local.php to sites/default/settings.local.php, and clear the Drupal caches:

if (file_exists(__DIR__ . '/settings.local.php')) {
  include __DIR__ . '/settings.local.php';

Please see https://www.drupal.org/node/1903374#drupal-render-cache for more information.


You need the CacheExclude, you can find it here:


You may also get inspirations for a customized application.

  • 2
    The question is about Drupal 8, while the module is for Drupal 7. – kiamlaluno Dec 7 '14 at 19:47
  • 1
    Now module available for D8. – Rajesh Vishwakarma Oct 10 '17 at 10:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.