Have you had any problems like this before? I appreciate your help.

When I'm an admin and update a node (custom module), I can see the changes I made (as an administrator). However, when I'm an anonymous user, just to check the data, I can't see the changes I made. (note: I have flushed the site, it will work, but only when I run flush)

I thought it was something related with the permission, from a Custom module I created, but I'm not sure of that. I included a permission.yml file and gave full access. It didn't work.

find the attached images:

enter image description here enter image description here I had built the code in the Controller folder/file: I have two public functions called retrieveArrayOne and retrieveArrayTwo. Each one has different data for me to query later (retrieving the data from these two functions).

public function mainviewlist() {
  $array1 = array($this->retrieveArrayTwo());
  $array2 = array($this->retrieveArrayOne());
  $retrieveData = array_merge($array1, $array2);
  $content = "<H2></H2>";
  foreach ($retrieveData as $key1 => $finalValues) {
    if ($key1 == 0) {
      foreach ($finalValues as $disCrop) {
        $content .= "<details>";
        $content .= '<summary>' . $disCrop . '</summary>';
        $content .= "</details>";
  return array(
    '#type'     => 'markup',
    '#markup'   => $content,
    '#attached' => array(
      'library' => array(


Here is the function from the $array1 and array2. Both are similar.

$query = \Drupal::entityQuery('node');
$query->condition('status', 1);
$query->condition('type', 'content-type-name');
$query->sort('title', 'ASC');
$entity = $query->execute();
$options = array();

foreach ($entity as $n) {
  $node = \Drupal\node\Entity\Node::load($n);
  $options[$node->id()] = $node->getTitle();
  $elementA[] = [//
    'nid'        => $node->get('nid')->value,
    'title'      => $node->get('title')->value,
    'body'       => $node->get('body')->value,
    'field_crop' => $node->get('field_crop')->value,

return $elementA;
  • This is not a permission issue, this is a caching issue. drupal.org/docs/8/api/cache-api/cache-api – Hudri Apr 10 '19 at 10:44
  • If this is a caching issue, then it shouldn't even work as an administrator. After I update a node from a Content Type, I can see the changes I made as an administrator but not as an anonymous user or after I log-out from the site. – Viktor Apr 11 '19 at 15:41
  • the problem is that I can't see the changes as an anonymous user or have access to see the content I made without logging in. – Viktor Apr 11 '19 at 15:42

OK, I found the problem.

In my routing file, I was missing:

    no_cache: TRUE

That fixed it.

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.