边缘端包括Symfony 2中的验证缓存

边缘端包括Symfony 2中的验证缓存,symfony,http-caching,esi,Symfony,Http Caching,Esi,是否可以在带有Symfony 2的ESI中使用验证缓存 如果查看该类,您可以看到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 3

是否可以在带有Symfony 2的ESI中使用验证缓存

如果查看该类,您可以看到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$request->headers->get('If-Modified-Since');和$request->getEtags()在ESI中不返回任何内容。。。所以缓存永远不新鲜

那么,对于$request,您有解决方案吗

如果验证HTTP缓存不能在ESI中工作,是否有其他方法来缓存部分HTTP缓存


谢谢大家!

我还没有将ESI与Symfony2一起使用过(目前)-但是Symfony2文档文章似乎建议这是一个非常简单的过程。

是的,使用过期缓存,这非常简单,而且可以工作!但在使用验证缓存时,它似乎不起作用。。。所以我试着调试它,但似乎不可能。。。