Syb*_*bio 5 http-caching symfony esi
是否可以在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;
}
Run Code Online (Sandbox Code Playgroud)
问题是ESI $ request-> headers-> get('If-Modified-Since'); 和$ request-> getEtags()在ESI中没有返回任何内容...所以缓存永远不会新鲜!
那么你有$请求的解决方案吗?
如果验证HTTP缓存无法在ESI中工作,是否有另一种方法来缓存部分?
谢谢 !
| 归档时间: |
|
| 查看次数: |
1630 次 |
| 最近记录: |