getNoCacheTagsForRequest example

if ($cacheControl->useNoCacheControl($this->request, $this->response, $shopId)) {
            $this->response->headers->set('cache-control', 'private, no-cache', true);

            return false;
        }

        $cacheTime = (int) $cacheControl->getCacheTime($this->request);

        $this->request->setParam('__cache', $cacheTime);
        $this->response->headers->set('cache-control', 'public, max-age=' . $cacheTime . ', s-maxage=' . $cacheTime, true);

        $noCacheTags = $cacheControl->getNoCacheTagsForRequest($this->request, $shopId);
        if (!empty($noCacheTags)) {
            $this->response->headers->set('x-shopware-allow-nocache', implode(', ', $noCacheTags), true);
        }

        $cacheCollector = $this->get('http_cache.cache_id_collector');

        $context = $this->get(ContextServiceInterface::class)->getShopContext();

        $this->setCacheIdHeader(
            $cacheCollector->getCacheIdsFromController($this->action, $context)
        );

        
$this->setContextCookie($request$context$response);
    }

    /** * @param int $shopId * * @return bool */
    private function hasMatchingNoCacheCookie(Request $request$shopId)
    {
        $routeTags = $this->getNoCacheTagsForRequest($request$shopId);

        $cookieTags = $this->getNoCacheTagsFromCookie($request);

        // Has cookie tag?         return !empty(array_intersect($routeTags$cookieTags));
    }

    /** * Returns array of nocache-tags in the request cookie * * <code> * array ( * 0 => 'detail-1', * 1 => 'checkout-1', * ) * </code> * * @return array<string> */
Home | Imprint | This part of the site doesn't use cookies.