美文网首页
http中的Cache-Control:must-revalid

http中的Cache-Control:must-revalid

作者: jun123123 | 来源:发表于2019-10-01 17:39 被阅读0次

    cache-control:must-revalidate首部会对过期后的缓存进行验证

    1.must-revalidate和no-cache的区别

    no-cache会强制验证缓存(无论缓存是否过期),而must-revalidate只会验证过期后的缓存。

    2.为什么需要must-revalidate

     当初看到这里的时候就产生了这个疑问,一般来说,缓存过期后就不能再使用,必须先进行验证,那么为什么还需要must-revalidate首部。

    :在http协议规范中,允许客户端在某些特殊情况下直接使用过期缓存,如校验请求错误时。而must-revalidate首部对过期缓存强制校验,如果遇到校验失败等情况,则返回504错误码。

    注:在浏览器中点击back/forward按钮返回上一页时,浏览器会直接使用本地缓存来打开页面,即使缓存已经过期。must-revalidate和no-cache都不能阻止这一行为,只有no-store禁止缓存才能阻止。

    相关文章

      网友评论

          本文标题:http中的Cache-Control:must-revalid

          本文链接:https://www.haomeiwen.com/subject/luxgaftx.html