简体   繁体   English

缓存控制不可变 Header

[英]Cache-control Immutable Header

I was reading about immutable header and i came across with this article saying that:我正在阅读关于不可变 header 的文章,我看到这篇文章说:

Cache-Control: max-age=365000000, immutable缓存控制:max-age=365000000,不可变

When a client supporting immutable sees this attribute it should assume that the resource, if unexpired, is unchanged on the server and therefore should not send a conditional revalidation for it (eg If-None-Match or If-Modified-Since) to check for updates.当支持不可变的客户端看到此属性时,它应该假定资源(如果未过期)在服务器上未更改,因此不应发送有条件的重新验证(例如 If-None-Match 或 If-Modified-Since)来检查更新。 Correcting possible corruption (eg shift reload in Firefox) never uses conditional revalidation and still makes sense to do with immutable objects if you're concerned they are corrupted.纠正可能的损坏(例如 Firefox 中的 shift reload)从不使用条件重新验证,如果您担心不可变对象已损坏,仍然可以使用它们。

source 资源

I cant understand this phrase "if unexpired, is unchanged on the server and therefore should not send a conditional revalidation"我无法理解这句话“如果未过期,则在服务器上未更改,因此不应发送有条件的重新验证”

Client, by default doesnt send a revalidation until the max-age is expired.客户端,默认情况下在 max-age 过期之前不会发送重新验证。

So whats the point define immutable in the first place?那么首先定义不可变有什么意义呢?

People pressing the refresh button.人们按下刷新按钮。

Facebook, who first proposed this immutable cache-control directive, have a good post on this about how it saved them a huge amount of requests, including this quote:最先提出这个不可变缓存控制指令的 Facebook 有一篇关于它如何为他们节省大量请求的好帖子,包括以下引用:

The problem with reloads重载的问题

The browser's reload button exists to allow the user to get an updated version of the current page.浏览器的重新加载按钮允许用户获取当前页面的更新版本。 In order to meet this goal, when you reload, browsers revalidate the page that you are currently on, even if that page hasn't expired yet.为了实现这一目标,当您重新加载时,浏览器会重新验证您当前所在的页面,即使该页面尚未过期。 However, they also go a step further and revalidate all sub-resources on the page — things like images and JavaScript files.但是,他们还 go 更进一步,并重新验证页面上的所有子资源 - 例如图像和 JavaScript 文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM