相关疑难解决方法(0)

Cache-Control有什么区别:max-age = 0和no-cache?

标题Cache-Control: max-age=0意味着内容被认为是陈旧的(并且必须立即重新获取),这实际上与之相同Cache-Control: no-cache.

caching http http-headers

616
推荐指数
8
解决办法
41万
查看次数

了解If-Modified-Since HTTP Header

我正在寻找一个试图使用If-Modified-Since请求对象的标头的缓存库.问题是这个标题永远不会被设置,它总是空白的,这对我来说是有意义的,看它是如何请求的.

你怎么能强制要求有一个If-Modified-Since标题?或者我是否会这样做.

这是我指的功能.

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)

php outputcache http cache-control if-modified-since

14
推荐指数
2
解决办法
4万
查看次数