Chrome中的HTTP2推送XMLHttpRequest缓存错误 [英] HTTP2 Push XMLHttpRequest Cache Miss in Chrome

查看:181
本文介绍了Chrome中的HTTP2推送XMLHttpRequest缓存错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 链接:< / images 

我设置Link标题以预加载发生的XHR请求。 /project_icon.png> ;;相对=预载荷;如=图像,< /分贝/ xhr_stuff取代; rel = preload

Chrome 57.0预加载并使用 /images/project_icon.png 很好,但它会预加载 / db / xhr_stuff ,然后错过刚刚检索到的副本,并在DOM完全加载后再次加载它。请求标头是相同的,除了由xhr启动的那个稍后的标头具有 x-requested-with:XMLHttpRequest set。请求之间的唯一区别是由链接标题启动的一个显示为类型:json ,第二个类型:xhr 在开发工具中。

根据XHR请求的文档,您只需省略 as = 属性。



获取缓存命中时缺少什么?

解决方案

您在推送时不提供as =属性将被页面忽略并重新加载。


根据docs for XHR request,you just omit as = attribute。


你在哪里看到这个?什么文件?

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?

解决方案

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"?

这篇关于Chrome中的HTTP2推送XMLHttpRequest缓存错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆