在Chrome开发人员工具中,资源的状态为已取消是什么意思?

本文探讨了在Chrome开发者工具中看到资源状态为已取消的情况,可能的原因包括DOM元素被删除、请求变得不必要的操作、网络问题、htaccess文件冲突、X-Frame-Options设置及服务器重定向问题等。建议检查htaccess文件和X-Frame-Options头标签,以及排查可能的超时设置问题。
摘要由CSDN通过智能技术生成

本文翻译自:What does status=canceled for a resource mean in Chrome Developer Tools?

What would cause a page to be canceled? 是什么导致页面被取消? I have a screenshot of the Chrome Developer Tools. 我有一个Chrome开发者工具的屏幕截图。

取消资源

This happens often but not every time. 这种情况经常发生,但并非每次都发生。 It seems like once some other resources are cached, a page refresh will load the LeftPane.aspx. 似乎一旦缓存了其他一些资源,页面刷新将加载LeftPane.aspx。 And what's really odd is this only happens in Google Chrome, not Internet Explorer 8. Any ideas why Chrome would cancel a request? 真正奇怪的是,这仅发生在Google Chrome中,而不是Internet Explorer 8中。为什么Chrome会取消请求?


#1楼

参考:https://stackoom.com/question/oOCN/在Chrome开发人员工具中-资源的状态为已取消是什么意思


#2楼

We fought a similar problem where Chrome was canceling requests to load things within frames or iframes, but only intermittently and it seemed dependent on the computer and/or the speed of the internet connection. 我们遇到了类似的问题,即Chrome取消了在框架或iframe中加载内容的请求,但只是间歇性的,它似乎取决于计算机和/或互联网的连接速度。

This information is a few months out of date, but I built Chromium from scratch, dug through the source to find all the places where requests could get cancelled, and slapped breakpoints on all of them to debug. 这些信息已经过了几个月,但是我从头开始构建Chromium,从源头开始挖掘,找到可以取消请求的所有位置,并在所有这些位置设置断点以进行调试。 From memory, the only places where Chrome will cancel a request: 从内存来看,Chrome唯一可以取消请求的地方:

  • The DOM element that caused the request to be made got deleted (ie an IMG is being loaded, but before the load happened, you deleted the IMG node) 导致发出请求的DOM元素被删除(即,正在加载IMG,但是在加载之前,您已删除IMG节点)
  • You did something that made loading the data unnecessary. 您所做的事情使加载数据变得不必要。 (ie you started loading a iframe, then changed the src or overwrite the contents) (即,您开始加载iframe,然后更改了src或覆盖了内容)
  • There are lots of requests going to the same server, and a network problem on earlier requests showed that subsequent requests weren't going to work (DNS lookup error, earlier (same) request resulted eg HTTP 400 error code, etc) 有许多请求发送到同一服务器,并且较早请求的网络问题表明后续请求将无法正常工作(DNS查找错误,导致较早(相同)的请求,例如HTTP 400错误代码等)

In our case we finally traced it down to one frame trying to append HTML to another frame, that sometimes happened before the destination frame even loaded. 在我们的案例中,我们最终将其追溯到一个框架,试图将HTML追加到另一框架,有时这是在目标框架加载之前发生的。 Once you touch the contents of an iframe, it can no longer load the resource into it (how would it know where to put it?) so it cancels the request. 触摸iframe的内容后,它将无法再将资源加载到其中(它将如何知道将其放置在哪里?),因此它将取消请求。


#3楼

I had the exact same thing with two CSS files that were stored in another folder outside my main css folder. 我有两个完全相同的东西,两个CSS文件存储在我的主要css文件夹之外的另一个文件夹中。 I'm using Expression Engine and found that the issue was in the rules in my htaccess file. 我正在使用Expression Engine,发现问题出在htaccess文件中的规则中。 I just added the folder to one of my conditions and it fixed it. 我只是将文件夹添加到我的条件之一中,并对其进行了修复。 Here's an example: 这是一个例子:

RewriteCond %{REQUEST_URI} !(images|css|js|new_folder|favicon.ico)

So it might be worth you checking your htaccess file for any potential conflicts 因此,可能值得您检查htaccess文件是否存在任何潜在冲突


#4楼

You might want to check the "X-Frame-Options" header tag. 您可能要检查“ X-Frame-Options”标题标签。 If its set to SAMEORIGIN or DENY then the iFrame insertion will be canceled by Chrome (and other browsers) per the spec . 如果将其设置为SAMEORIGIN或DENY,则Chrome(和其他浏览器)将根据规范取消插入iFrame。

Also, note that some browsers support the ALLOW-FROM setting but Chrome does not. 另外,请注意,某些浏览器支持ALLOW-FROM设置,但Chrome不支持。

To resolve this, you will need to remove the "X-Frame-Options" header tag. 要解决此问题,您将需要删除“ X-Frame-Options”标题标签。 This could leave you open to clickjacking attacks so you will need to decide what the risks are and how to mitigate them. 这可能使您容易遭受点击劫持攻击,因此您需要确定风险是什么以及如何减轻风险。


#5楼

Here's what happened to me: the server was returning a malformed "Location" header for a 302 redirect. 这是我发生的事情:服务器为302重定向返回了格式错误的“位置”标头。 Chrome failed to tell me this, of course. 当然,Chrome无法告诉我这一点。 I opened the page in firefox, and immediately discovered the problem. 我在firefox中打开页面,并立即发现了问题。 Nice to have multiple tools :) 很高兴拥有多个工具:)


#6楼

就我而言,我发现这是jquery全局超时设置,一个jquery插件将全局超时设置为500ms,因此当请求超过500ms时,chrome将取消该请求。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值