跳到主要内容

4.9.2. Stale Response

4.9.2. Stale Response

当 cached response 变为 stale (其 freshness lifetime 已过期) 时, 通常需要先向 origin server 验证, 然后才能再次使用. 不过, 有些机制允许在特定条件下使用 stale response.

application 可能希望使用这些机制来提高 availability 或 performance:

  • Cache-Control: stale-while-revalidate 允许 cache 在后台异步重新验证 stale response 的同时提供这些 response.

  • Cache-Control: stale-if-error 允许 cache 在 origin server 不可达时提供 stale response.

关于这些 extension 的更多信息见 [RFC5861].

application SHOULD 考虑允许 stale response 是否适合其 use case. 对某些 application 而言, 提供 stale data 可能可以接受, 甚至优于失败; 而对其他 application 则可能并非如此.