server - HTTP/2 服务器推送和浏览器缓存

标签 server push browser-cache http2

我阅读了一些关于 HTTP/2 服务器推送的文档。

一位博主说:

However, there is a very headache problem in server push. If the browser has already cached the resource files which are to be pushed, pushing is just a waste of bandwidth.

另一个人说:

Since server push will send the assets to the client as distinct HTTP objects (each with its own Cache-Control headers), they can be cached by the browser just like anything else.

我的问题是,HTTP/2 推送和浏览器缓存都运行良好吗?或者,如果我为某些 Assets 激活 HTTP/2 推送功能,浏览器缓存将不适用于这些 Assets ?

最佳答案

如果你推送了一个资源,页面需要使用它,它会被保存到浏览器缓存中,以供下次使用。

问题在于,如果您更改资源并再次推送,但旧版本已经在浏览器缓存中并且缓存控制 header 显示它仍然有效,那么浏览器将使用旧的缓存版本,尽管您已经推出了更新的版本。所以这是一个浪费的插入。

关于它的好博文 herehere还有Chapter 5 of my book即将发布也涵盖了这一点。

关于server - HTTP/2 服务器推送和浏览器缓存,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53935144/

相关文章:

javascript - 强制刷新 js/css/html 更改 webapp 上的缓存

java - 在嵌入式 Jetty 中与 Restful 一起部署网页

PHP - 没有这样的文件或目录(LAMP 服务器)

python - 将 CURL Post 转换为 Python 请求失败

windows - 用于推送通知的 WNS 或 MPNS?

ios - 使用 iOS Storyboard Seque "Model"或 "Push"样式时是否存在内存泄漏(或对象的过度实例化)?

php 将数组放入数组中

font-face - 缓存字体字体

java - 用java加载缓存中的数据

sql-server - 在 Server 2008 R2 上禁用旧 SSL 时站点加载和 sql 连接出现问题