5

Symfony 2 の ESI で検証キャッシュを使用することは可能ですか?

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 $request->headers->get('If-Modified-Since'); です。$request->getEtags() は ESI で何も返さないため、キャッシュは決して新鮮ではありません!

$request の解決策はありますか?

検証 HTTP キャッシュが ESI で機能しない場合、部分をキャッシュする別の方法はありますか?

ありがとうございました !

4

1 に答える 1

1

私は Symfony2 で ESI を (まだ) 使用していませんが、Symfony2 のドキュメント記事Using Edge Side Includesは、それが非常に簡単なプロセスであることを示唆しているようです。

于 2012-03-11T19:42:01.287 に答える