在"Cache-Control:no-cache,must-revalidate"中使用"must-revalidate"是多么必要

nop*_*ole 7 http cache-control http-headers

经常我用

Cache-Control: no-cache
Run Code Online (Sandbox Code Playgroud)

要么

Cache-Control: max-age=0
Run Code Online (Sandbox Code Playgroud)

规范说must-revalidatemax-stale......(服务器问题max-stale?)

因此,如果对于普通的Web服务器,Apache或带有Mongrels的Rails,那么我认为通常没有max-stale,所以must-revalidate不需要?

小智 7

must-revalidate应该由服务器指定,以便客户端获得陈旧的响应是不正确的(而不仅仅是次优的).这适用于max-stale您提到的所有请求.如果缓存暂时失去与源的连接(Warning在这种情况下允许缓存返回带有标头的陈旧条目),它也适用.话虽如此,我认为你是正确的,特别是在实践中不需要这个指令; 最常见的情况是,原始设备希望让客户端缓存资源的副本(用于带宽保护),但始终在使用前对其进行验证,如下所示:

Cache-Control: private, max-age=0, must-revalidate