cache-control
选项,请求也可以包含这些选项。虽然我理解服务器响应可以有意义地利用这些选项,但我不清楚为什么在请求中也需要它们。不幸的是,我在互联网上找不到任何能解决问题的答案。
有没有人有主意?
cache-control
选项,请求也可以包含这些选项。Cache-Control
头部用于指定请求/响应链中缓存的指令。这些缓存指令是单向的,即请求中存在指令并不意味着相同的指令会在响应中给出。
以下是可以在请求Cache directives are identified by a token, to be compared case-insensitively, and have an optional argument, that can use both token and quoted-string syntax. For the directives defined below that define arguments, recipients ought to accept both forms, even if one is documented to be preferred. For any directive not defined by this specification, a recipient MUST accept both forms.
Cache-Control = 1#cache-directive cache-directive = token [ "=" ( token / quoted-string ) ]
Cache-Control
头部中使用的 指令:
[...]
max-age
请求指令表示客户端不愿意接受响应的年龄大于指定秒数的响应。[...]该指令使用参数语法的标记形式:例如,
max-age=5
而不是max-age="5"
。[...]
[...]
max-stale
请求指令表示客户端愿意接受已超过其新鲜度生命周期的响应。 [...]该指令使用参数语法的令牌形式:例如,
max-stale=10
而不是max-stale="10"
。 [...]
[...]
min-fresh
请求指令表示客户端愿意接受其当前年龄加上指定秒数后的新鲜度生命周期不少于的响应。 [...]该指令使用参数语法的令牌形式:例如,
min-fresh=20
而不是min-fresh="20"
。 [...]
no-cache
请求指令表示缓存在未经过源服务器的成功验证后,不能使用已存储的响应来满足请求。
no-store
请求指令表示缓存不得存储此请求或任何响应的任何部分。[...]
no-transform
请求指令表示中间人(无论是否实现缓存)不得转换负载[...]。
only-if-cached
请求指示客户端只希望获取已存储的响应。[...]
类似地,RFC 7234 还定义了可以在响应中使用的 指令,用于 Cache-Control
标头。