为什么 Google Api 字体 last-modified 不断变化?

Why Google Api fonts last-modified keep changing?

当我请求 Google Api 字体(例如 https://fonts.googleapis.com/css?family=Roboto:400)时,last-modified header 总是更改为当前时间.

因此缓存不起作用,每次加载都必须下载文件。是否有一个原因?我应该下载文件并将其托管在我的服务器上吗?

Should I download the file and host it on my server?

绝对不是,因为 CSS 文件的内容是动态的,每个用户代理都有不同的内容。这是因为并非所有浏览器都支持所有字体格式。有些需要 WOFF/WOFF2,有些需要 EOT、TTF 或 SVG。通过静态下载和提供文件,您将破坏对所有其他浏览器的字体支持。

有趣的是,我根本没有看到 last-modified header:

HTTP/1.1 200 OK
Access-Control-Allow-Origin: *
Content-Type: text/css
Alt-Svc: clear
Alternate-Protocol: 443:quic,p=0
X-XSS-Protection: 1; mode=block
Server: GSE
Expires: Mon, 14 Dec 2015 09:14:21 GMT
Timing-Allow-Origin: *
Cache-Control: private, max-age=86400
Date: Mon, 14 Dec 2015 09:14:21 GMT
Content-Length: 222
Connection: close
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN

Expires header 确实与 Date 相同 - 因此它在加载资源时过期。 Cache-Controlmax-age 选项虽然具有更高的优先级。所以文件应该被浏览器缓存1天。