lookup() 보호된 메소드

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.
protected lookup ( Request $request, boolean $catch = false ) : Response
$request Symfony\Component\HttpFoundation\Request A Request instance
$catch boolean whether to process exceptions
리턴 Symfony\Component\HttpFoundation\Response A Response instance
예제 #1
0
 /**
  * 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;
 }
예제 #2
0
파일: AppCache.php 프로젝트: nhp/shopware-4
    /**
     * 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;
    }