HTTP2 Push XMLHttpRequest Cache Miss in Chrome

三世轮回 提交于 2019-12-02 05:42:40

问题


I'm setting the Link header to preload an XHR request that happens on load.

Link: </images/project_icon.png>; rel=preload; as=image,</db/xhr_stuff>; rel=preload

Chrome 57.0 preloads and uses the /images/project_icon.png just fine but it preloads /db/xhr_stuff and then misses the copy it just retrieved and loads it a second time after the DOM completely loads. The request headers are identical except the one later one initiated by the xhr has x-requested-with:XMLHttpRequest set. The only other difference between the requests is the one initiated by the link header shows up as Type: json and the second Type: xhr in the Developer Tools.

According to the docs for XHR request, you just omit the as= attribute.

What is missing to get a cache hit?


回答1:


If you don't provide the "as=" attribute when you push it will be ignored by the page and loaded again.

According to the docs for XHR request, you just omit the as= attribute.

Where do you see this? What "docs"?



来源:https://stackoverflow.com/questions/43397507/http2-push-xmlhttprequest-cache-miss-in-chrome

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!