我阅读了一些关于 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 显示它仍然有效,那么浏览器将使用旧的缓存版本,尽管您已经推出了更新的版本。所以这是一个浪费的插入。
关于它的好博文 here和 here还有Chapter 5 of my book即将发布也涵盖了这一点。
关于server - HTTP/2 服务器推送和浏览器缓存,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53935144/