hook_node_view() is not working I am building a module for Drupal 8 which needs to use hook_node_view(). I tried the following code

&lt;?php

/**
 * @file
 * Demonstrates the possibilities of forms in Drupal 8.
 */

use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Entity\Node;
use Drupal\Core\Entity\Display\EntityViewDisplayInterface;
use Drupal\Core\Entity\EntityInterface;

/**
 * Implements hook_form_alter()
 */
function demo_form_form_alter(&amp;$form, FormStateInterface $form_state, $form_id) {
  drupal_set_message(t('Found a form with ID %form_id', array('%form_id' =&gt; $form_id)));
}

/**
 * Implements hook_node_view()
 */
function demo_form_node_view(array &amp;$build, \Drupal\Core\Entity\EntityInterface $entity, \Drupal\Core\Entity\Display\EntityViewDisplayInterface $display, $view_mode) {
   drupal_set_message(t('its working'));
}

/**
 * Implements hook_form_FORM_ID_alter().
 *
 * Only alters the Search form 'search_block_form'.
 */
function demo_form_form_search_block_form_alter(&amp;$form, FormStateInterface $form_state, $form_id) {
  $form['hello'] = array(
    '#markup' =&gt; t('Go ahead, try me ...') . '&lt;br /&gt;',
    '#weight' =&gt; -1,
  );
}


I can't see any message from demo_form_node_view(). If the hook was correct, it should have shown the message. I am new to Drupal and I can't figure out why it is not working.
In Drupal 8, the core Drupal hook hook_entity_view() is only called when the entity is "being assembled before rendering". See the documentation at https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Entity!entity.api.php/function/hook_entity_view

After the entity has been rendered, core Drupal will cache the rendered entity and serve the rendered entity from the cache when needed. The entity is not rendered every time it is used. So BY DESIGN hook_entity_view() will not be called again when the rendered entity is loaded from the cache, it will only be called when the entity needs to be re-rendered - that is, when the entity is changed and/or the cache of that entity is invalidated.

This behavior is different from the way it worked in Drupal 7 because Drupal 7 did not cache rendered entities like this.