storeResponse example

$request->get('includes', [])
        );

        $symfonyResponse = $this->scriptResponseEncoder->encodeToSymfonyResponse(
            $responseHook->getScriptResponse(),
            $fields,
            \str_replace('-', '_', 'store_api_' . $hookName . '_response')
        );

        $cacheConfig = $responseHook->getScriptResponse()->getCache();
        if ($cacheKey && $cacheConfig->isEnabled()) {
            $this->storeResponse($cacheKey$cacheConfig$symfonyResponse);
        }

        return $symfonyResponse;
    }

    private function readFromCache(?string $cacheKey, SalesChannelContext $context, Request $request): ?Response
    {
        if (!$cacheKey) {
            return null;
        }

        

  protected function fetch(Request $request$type = self::MAIN_REQUEST, $catch = TRUE) {
    /** @var \Symfony\Component\HttpFoundation\Response $response */
    $response = $this->httpKernel->handle($request$type$catch);

    // Only set the 'X-Drupal-Cache' header if caching is allowed for this     // response.     if ($this->storeResponse($request$response)) {
      $response->headers->set('X-Drupal-Cache', 'MISS');
    }

    return $response;
  }

  /** * Stores a response in the page cache. * * @param \Symfony\Component\HttpFoundation\Request $request * A request object. * @param \Symfony\Component\HttpFoundation\Response $response * A response object that should be stored in the page cache. * * @returns bool */
Home | Imprint | This part of the site doesn't use cookies.