我有一个返回 json 和 pbf 的网络服务器。我正在使用 etag 来允许缓存。这适用于 chrome 上的 json 和 pbf,但不适用于 Firefox。 Firefox 似乎忽略了标题。
我尝试了不同的缓存标头,但似乎都不起作用。
这是 json 的第二个请求(使用缓存的请求)的响应+请求标头
回应:
HTTP/2 304
vary: Origin,Accept-Encoding,Authorization
x-xss-protection: 1; mode=block
x-content-type-options: nosniff
etag: "-1633907450"
content-encoding: gzip
date: Wed, 10 Apr 2024 14:07:01 GMT
X-Firefox-Spdy: h2
请求(浏览器)
GET *endpoint* HTTP/2
Host: *host*
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:124.0) Gecko/20100101 Firefox/124.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate, br
Connection: keep-alive
Upgrade-Insecure-Requests: 1
Sec-Fetch-Dest: document
Sec-Fetch-Mode: navigate
Sec-Fetch-Site: none
Sec-Fetch-User: ?1
If-None-Match: "-1633907450"
这是 pbf 的:
回应:
HTTP/2 200
vary: Origin,Accept-Encoding,Authorization
x-xss-protection: 1; mode=block
x-content-type-options: nosniff
etag: "1761268274"
cache-control: max-age=14400, public
content-encoding: gzip
content-type: application/x-protobuf
content-length: 265
date: Wed, 10 Apr 2024 14:02:22 GMT
X-Firefox-Spdy: h2
请求(来自浏览器):
GET *endpoint* HTTP/2
Host: *host*
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:124.0) Gecko/20100101 Firefox/124.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate, br
Connection: keep-alive
Upgrade-Insecure-Requests: 1
Sec-Fetch-Dest: document
Sec-Fetch-Mode: navigate
Sec-Fetch-Site: none
Sec-Fetch-User: ?1
Firefox 不支持 pbf 等文件下载的缓存。