mustRevalidate() public method

This method indicates that the response must not be served stale by a cache in any circumstance without first revalidating with the origin. When present, the TTL of the response should not be overridden to be greater than the value provided by the origin.
public mustRevalidate ( ) : boolean
return boolean true if the response must be revalidated by a cache, false otherwise
コード例 #1
0
 public function track(Request $request)
 {
     $this->request = $request;
     $referer = $this->request->query->get('utmr', '');
     $path = $this->request->query->get('utmp', '');
     $account = $this->request->query->get('utmac');
     $userAgent = $this->request->server->get('HTTP_USER_AGENT', '');
     $visitorId = $this->request->cookies->get($this->cookieName);
     if (empty($visitorId)) {
         $visitorId = $this->getVisitorId($this->getGuidHeader(), $account, $userAgent);
     }
     $url = $this->constructGifUrl($referer, $path, $account, $visitorId, $this->maskVisitorIp());
     $this->browser->get($url, array('Accept-Language: ' . $this->request->server->get('HTTP_ACCEPT_LANGUAGE'), 'User-Agent: ' . $userAgent));
     $cookie = new Cookie($this->cookieName, $visitorId, time() + $this->cookiePersistence, $this->cookiePath, $this->request->getHost());
     $response = new Response();
     $response->headers->add(array('Content-Type' => 'image/gif', 'Pragma' => 'no-cache'));
     $response->setPrivate();
     $response->mustRevalidate();
     $response->setExpires(new \DateTime('-10 year'));
     $response->setContent(join($this->gifData));
     $response->headers->setCookie($cookie);
     return $response;
 }
コード例 #2
0
 public function testMustRevalidate()
 {
     $response = new Response();
     $this->assertFalse($response->mustRevalidate());
 }
コード例 #3
0
ファイル: ResponseTest.php プロジェクト: ayoah/symfony
 public function testMustRevalidateWithProxyRevalidateCacheControlHeader()
 {
     $response = new Response();
     $response->headers->set('cache-control', 'proxy-revalidate');
     $this->assertTrue($response->mustRevalidate());
 }