code: public function beforeAction($action)
      {
          if (!$this->enabled) {
              return true;
          }
  
          $this->cache = Instance::ensure($this->cache, 'yii\caching\CacheInterface');
  
          if (is_array($this->dependency)) {
              $this->dependency = Yii::createObject($this->dependency);
          }
  
          $response = Yii::$app->getResponse();
          $data = $this->cache->get($this->calculateCacheKey());
          if (!is_array($data) || !isset($data['cacheVersion']) || $data['cacheVersion'] !== static::PAGE_CACHE_VERSION) {
              $this->view->pushDynamicContent($this);
              ob_start();
              ob_implicit_flush(false);
              $response->on(Response::EVENT_AFTER_SEND, [$this, 'cacheResponse']);
              Yii::debug('Valid page content is not found in the cache.', __METHOD__);
              return true;
          }
  
          $this->restoreResponse($response, $data);
          Yii::debug('Valid page content is found in the cache.', __METHOD__);
          return false;
      }
docs: This method is invoked right before an action is to be executed (after all possible filters.)
  You may override this method to do last-minute preparation for the action.
  @param Action $action the action to be executed.
  @return bool whether the action should continue to be executed.