html - 为什么 Firefox 忽略基于范围的查询的缓存控制?

标签 html http http-headers html5-audio http-caching

Web 服务器能够将媒体(本例中为音频)流式传输到浏览器。浏览器使用 HTML5 控件来播放媒体。然而,我发现的是 Firefox 正在缓存媒体,即使我(相信我)明确告诉它不要这样做。我有一种预感,它与 206 部分内容响应有关,因为具有完整 200 OK 响应的常规“非范围”GET 不会被缓存。 Chrome (27) 可以处理此问题,但 Firefox (21) 不会:

HTTP/1.1 206 Partial Content
Date: Tue, 21 May 2013 17:24:29 GMT
Expires: 0
Pragma: no-cache
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Content-Disposition: attachment; filename="audio.wav"
Content-Type: audio/x-wav
Connection: close
Accept-Ranges: bytes
Content-Range: bytes 0-218923/218924

有人知道如何让 Firefox 不缓存这个吗?当我点击播放其他同名音频文件时,Firefox 只会播放 session 中被点击(缓存)的第一个文件,而不是从服务器重新获取新文件。

请注意 this question似乎直接询问/回答这个,但它不起作用......我使用提到的标题。

感谢您的帮助。

编辑:我也尝试添加一个 ETag: header ,但 Firefox 仍然缓存原始响应。

编辑:包含要匹配的 Content-Length: header (本例中为 218924)似乎不会影响问题。

编辑:我已经在 bugzilla.mozilla.org 上提交了一个错误,但此时没有任何事件。

最佳答案

您的 Firefox 正在执行 rfc2616 的第 13.8 节.所以这种行为是可以的。

13.8 Errors or Incomplete Response Cache Behavior

A cache that receives an incomplete response (for example, with fewer bytes of data than specified in a Content-Length header) MAY store the response. However, the cache MUST treat this as a partial response. Partial responses MAY be combined as described in section 13.5.4; the result might be a full response or might still be partial. A cache MUST NOT return a partial response to a client without explicitly marking it as such, using the 206 (Partial Content) status code. A cache MUST NOT return a partial response using a status code of 200 (OK).

部分响应可能会(或可能不会)被存储。所以 Chrome 和 Firefox 都遵守规则。

关于html - 为什么 Firefox 忽略基于范围的查询的缓存控制?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16676117/

相关文章:

css - 左右菜单 - 位置固定和中间内容应该是可滚动的

c++ - 从 std::string 转换为 const char* 导致 valgrind 出现 'Syscall param socketcall.sendto(msg) points to unaddressable byte(s)' 错误

android - 在 Android 中将 header 添加到 Google Cloud Endpoint

html - Web 浏览器不显示 svg 文件

javascript - html:单击链接时执行功能,获得警报,然后重定向到另一个页面

HTTP查询和URI编码疑惑

iphone - 向服务器发送请求时如何添加设备信息?

http - 传输编码分块的 HTTP 响应中的最大块大小是多少?

javascript - 单击时突出显示单元格边框颜色,单击时变回其他颜色

c# - 是什么导致 'Thread was being aborted' 异常随机发生并向浏览器显示 HTTP header 和部分 HTML?