5
是否可以在Symfony 2中使用ESI中的验证缓存?边缘包括Symfony 2中的验证缓存
如果你看看HttpFoundation Response类,你可以看到isNotModified如何工作的:
/**
* Determines if the Response validators (ETag, Last-Modified) match
* a conditional value specified in the Request.
*
* If the Response is not modified, it sets the status code to 304 and
* removes the actual content by calling the setNotModified() method.
*
* @param Request $request A Request instance
*
* @return Boolean true if the Response validators match the Request, false otherwise
*
* @api
*/
public function isNotModified(Request $request)
{
$lastModified = $request->headers->get('If-Modified-Since');
$notModified = false;
if ($etags = $request->getEtags()) {
$notModified = (in_array($this->getEtag(), $etags) || in_array('*', $etags)) && (!$lastModified || $this->headers->get('Last-Modified') == $lastModified);
} elseif ($lastModified) {
$notModified = $lastModified == $this->headers->get('Last-Modified');
}
if ($notModified) {
$this->setNotModified();
}
return $notModified;
}
的问题是,ESI $请求 - >包头中>的get( '如果-Modified-Since的');和$ request-> getEtags()在ESI中没有任何返回......所以缓存永远不会是新鲜的!
那么你有$ request的解决方案吗?
如果验证HTTP缓存无法在ESI中工作,是否有另一种方法来缓存部分?
谢谢!
是与过期缓存这真的很容易,它的工作原理!但它似乎不工作时使用验证缓存...所以我试图调试它,它似乎是不可能的... – Sybio 2012-03-13 14:11:02