chrome 发送额外请求怎么办? [英] What to do with chrome sending extra requests?

查看:29
本文介绍了chrome 发送额外请求怎么办?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

谷歌浏览器发送多个请求来获取页面,这显然不是错误,而是一项功能.而我们作为开发人员只需要处理它.

Google chrome sends multiple requests to fetch a page, and that's -apparently- not a bug, but a feature. And we as developers just have to deal with it.

就我能在五分钟内挖掘出来的内容而言,chrome 这样做只是为了让浏览速度更快,所以如果一个连接丢失,第二个将接管.

As far as I could dig out in five minutes, chrome does that just to make the surfing faster, so if one connection gets lost, the second will take over.

我想如果网站开发得很好,那么它的功能不会因此而中断,因为多个请求并不新鲜.

I guess if the website is well developed, then it's functionality won't break by this, because multiple requests are just not new.

但我不确定我是否已经考虑了此功能可能产生的所有情况.

But I'm just not sure if I have accounted for all the situations this feature can produce.

会不会有什么特殊情况?处理这些问题的最佳做法是什么?

Would there be any special situations? Any best practices to deal with them?

更新 1:现在我明白为什么我的银行页面在我用 chrome 打开页面时会抛出错误!它说:应该只打开浏览器的一个窗口."这就是他们对安全威胁的解决方案?!!

Update 1: Now I see why my bank's page throws an error when I open the page with chrome! It says: "Only one window of the browser should be open." That's their solution to security threats?!!

推荐答案

最好的办法是遵循标准的 Web 开发最佳实践:不要因 GET 调用而更改应用程序状态.

Your best bet is to follow standard web development best practises: don't change application state as a result of a GET call.

如果您担心,我建议您更新您的数据层单元测试,以便重复和复制 GET 调用.确保它们返回相同的数据.

If you're worried I recommend updating your data layer unit tests for GET calls to be duplicated & ensure they return the same data.

(顺便说一下,我在 Chrome 8.0.552.224 中没有看到这种行为,是不是很新?)

(I'm not seeing this behaviour with Chrome 8.0.552.224, by the way, is very new?)

这篇关于chrome 发送额外请求怎么办?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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