code: public function cacheResponse()
      {
          $this->view->endCache();
          $response = Yii::$app->getResponse();
          $data = [
              'format' => $response->format,
              'version' => $response->version,
              'statusCode' => $response->statusCode,
              'statusText' => $response->statusText,
          ];
          if (!empty($this->cacheHeaders)) {
              $headers = $response->getHeaders()->toArray();
              if (is_array($this->cacheHeaders)) {
                  $filtered = [];
                  foreach ($this->cacheHeaders as $name) {
                      $name = strtolower($name);
                      if (isset($headers[$name])) {
                          $filtered[$name] = $headers[$name];
                      }
                  }
                  $headers = $filtered;
              }
              $data['headers'] = $headers;
          }
          if (!empty($this->cacheCookies)) {
              $cookies = $response->getCookies()->toArray();
              if (is_array($this->cacheCookies)) {
                  $filtered = [];
                  foreach ($this->cacheCookies as $name) {
                      if (isset($cookies[$name])) {
                          $filtered[$name] = $cookies[$name];
                      }
                  }
                  $cookies = $filtered;
              }
              $data['cookies'] = $cookies;
          }
          $this->cache->set($this->calculateCacheKey(), $data, $this->duration, $this->dependency);
          echo ob_get_clean();
      }
docs: Caches response properties.
  @since 2.0.3