HTTP/2 服务器推送和浏览器缓存
HTTP/2 Server Push and Browser Cache
我阅读了一些关于 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 推送和浏览器缓存都运行良好吗?或者,如果我为某些资产激活 HTTP/2 推送功能,浏览器缓存将不适用于这些资产?
如果你推送了一个资源,页面需要使用它,它会被保存到浏览器缓存中,以供下次使用。
问题出在你换了资源,再push,但是老版本已经在浏览器缓存中,缓存控制headers说还有效,那么浏览器就会使用旧版本缓存版本,尽管你已经推送了一个更新的版本。所以这是一个浪费的推送。
不错的博客 post 上 here and here and also Chapter 5 of my book 即将发布也涵盖了这一点。
我阅读了一些关于 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 推送和浏览器缓存都运行良好吗?或者,如果我为某些资产激活 HTTP/2 推送功能,浏览器缓存将不适用于这些资产?
如果你推送了一个资源,页面需要使用它,它会被保存到浏览器缓存中,以供下次使用。
问题出在你换了资源,再push,但是老版本已经在浏览器缓存中,缓存控制headers说还有效,那么浏览器就会使用旧版本缓存版本,尽管你已经推送了一个更新的版本。所以这是一个浪费的推送。
不错的博客 post 上 here and here and also Chapter 5 of my book 即将发布也涵盖了这一点。