Answer the question
In order to leave comments, you need to log in
Yii2 -> how to cache a widget?
There were difficulties with caching the widget
The widget itself:
class FooterWidget extends Widget
{
public function run()
{
$io = Common::findOne(['id' => '1']);
return $this->render('footer', compact('io'));
}
}
Answer the question
In order to leave comments, you need to log in
Can be cached as a snippet https://github.com/yiisoft/yii2/blob/master/docs/g... Something like:
if ($this->beginCache($id, ['duration' => 3600])) {
echo \app\widgets\Menu::widget();
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question