[英]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.