[英]How can I set $build['#cache']['max-age'] in the following code?
在我的drupal 8自定义模块中,我使用block来显示当前文章页面的下一个和上一个链接。 但是,切换节点时不会由于缓存而更改链接。 如何限制此块的缓存? 我无法解决这个问题。
public function build() {
/**
* {@inheritdoc}
*/
$node = \Drupal::request()->attributes->get('node');
$created_time = $node->getCreatedTime();
$nextprevlinks ="";
$nextprevlinks .= $this->generateNext($created_time);
$nextprevlinks .= $this->generatePrevious($created_time);
return array('#markup' => $nextprevlinks);
}
以防万一有人像我一样放屁。
这就是我现在的回报:
return array('#markup' => $nextprevlinks,
'#cache' => array("max-age" => 0),
);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.