如何处理Chrome发送额外请求? [英] What to do with chrome sending extra requests?

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

问题描述

Google 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?!!

推荐答案

您最好的选择是遵循标准的网络开发最佳实践:不要改变应用程序状态作为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天全站免登陆