http - 缓存控制中的 max-age=0 和 max-age=-1 有什么区别?

标签 http caching cache-control max-age

两个 header Cache-control: max-age=0Cache-control: max-age=-1 之间的浏览器行为有何不同?

如果浏览器收到 max-age=0,它会立即重新验证缓存。 如果浏览器收到 max-age=10,它将在 10 秒后重新验证缓存。 max-age=-1 时浏览器的行为是什么?是否与 max-age=0 一样?如果是,为什么我们需要两者?

最佳答案

max-age采用匹配 delta-seconds 的参数:

The delta-seconds rule specifies a non-negative integer, representing
time in seconds.

  delta-seconds  = 1*DIGIT

max-age=-1 因此不是有效的指令,规范也没有定义解释。规范建议:

Caches are
encouraged to consider responses that have invalid freshness
information to be stale.

关于http - 缓存控制中的 max-age=0 和 max-age=-1 有什么区别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47470325/

相关文章:

apache-flex - 将 CURL 转换为 FLEX HTTP 请求

ruby-on-rails - Rails 是否维护多个 URL 数组参数的顺序

android - RxJava 和 Android : how to invalidate observable that use cache()?

iOS DispatchQueue 在后台线程缓存的安全性

c++ - 如何 https `GET` 来自 azure 存储 CDN 的文件的新拷贝?

asp.net - ScriptResource.axd 请求的特定缓存问题

php - 如何为我的站点创建一个 "clear cache"按钮?

java - 在 HTTP Servlet 中正确地流式传输输入和输出

javascript - 客户端缓存(使用 JavaScript)

VBA setRequestHeader "Authorization"失败