When a matching cache entry is found and is fresh, it uses it as the
response without forwarding any request to the backend. When a matching
cache entry is found but is stale, it attempts to "validate" the entry with
the backend using conditional GET. When no matching cache entry is found,
it triggers "miss" processing.
/** * Lookups a Response from the cache for the given Request. * * {@inheritDoc} * * @param Request $request * @param bool $catch * @return Response */ protected function lookup(Request $request, $catch = false) { $response = parent::lookup($request, $catch); // If Response is not fresh age > 0 AND contains a mathing no cache tag if ($response->getAge() > 0 && $this->containsNoCacheTag($request, $response)) { $response = $this->fetch($request); } if (!$this->options['debug']) { // Hide headers from client $response->headers->remove('x-shopware-allow-nocache'); $response->headers->remove('x-shopware-cache-id'); } return $response; }
/** * Lookups a Response from the cache for the given Request. * * {@inheritDoc} * * @param \Symfony\Component\HttpFoundation\Request $request * @param bool $catch * @return \Symfony\Component\HttpFoundation\Response */ protected function lookup(Request $request, $catch = false) { $response = parent::lookup($request, $catch); if ($response->getAge() > 0 && $response->headers->has('x-shopware-allow-nocache') && $request->cookies->has('nocache')) { $cacheTag = $response->headers->get('x-shopware-allow-nocache'); $cacheTag = explode(', ', $cacheTag); foreach($cacheTag as $cacheTagValue) { if(strpos($request->cookies->get('nocache'), $cacheTagValue) !== false) { $response = $this->fetch($request); break; } } } if (!$this->options['debug']) { $response->headers->remove('x-shopware-allow-nocache'); $response->headers->remove('x-shopware-cache-id'); } return $response; }