是什么导致Chrome在本地主机上的服务器上针对缓存内容提供net :: ERR_FAILED? [英] What can cause Chrome to give an net::ERR_FAILED on cached content against a server on localhost?

查看:54
本文介绍了是什么导致Chrome在本地主机上的服务器上针对缓存内容提供net :: ERR_FAILED?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在构建Web服务器并尝试进行测试.服务器在 localhost:888 上运行,并且第一次加载Web应用程序时,一切正常.但是,如果我尝试重新加载页面,一堆 XmlHttpRequest 请求将失败,并出现 net :: ERR_FAILED .通过在服务器代码中放置断点,我可以验证请求实际上从未传入.

I'm building a web server and trying to test things. The server is running on localhost:888, and the first time I load the web app, everything works. But if I try to reload the page, a bunch of XmlHttpRequest requests fail with net::ERR_FAILED. By putting breakpoints in the server code, I can verify that the requests are never actually coming in.

这不是连接失败,因为连接首次成功.它成功一次然后在以后失败的事实意味着它可能与缓存有关,但是服务器代码中没有任何内容可以设置 cache-control 标头.因此,我通过将服务器安装在实际的Web服务器上进行了测试.第一次,所有事情都需要花费时间.第二次,它们都立即加载,因此这绝对与缓存有关

This isn't a connection failure, as the connection succeeds the first time. The fact that it succeeds once and then fails later implies that it might be caching-related, but there's nothing in the server code that sets the cache-control header. So I tested it by putting the server up on an actual web server. The first time, everything had to take its time loading; the second time, it all loaded instantly, so this is definitely cache-related

这是一个运行在 http.sys (无IIS)之上的自定义服务器,默认情况下似乎正在缓存内容,然后在后续运行中无法从中加载内容,但这仅是当我的服务器在本地主机上运行时;在网络上,效果很好.据我所知,Chrome浏览器中的 net :: ERR_FAILED 是一个通用的出现错误,我们没有对您有用的信息"消息,因此我有点卡在这里.有谁知道是什么原因造成的?

This is a custom server running on top of http.sys (no IIS), and it appears that things are getting cached by default and then failing to load from it on subsequent runs, but only when my server is running on localhost; on the Web, it works fine. As near as I can tell, net::ERR_FAILED is a generic "something went wrong and we've got no useful information for you" message in Chrome, so I'm kind of stuck here. Does anyone know what could be causing this?

推荐答案

我遇到了类似的问题.我已在devtools的网络"选项卡中将请求复制为获取.

I run into similar problem. I have copied request as fetch in Network tab in devtools.

然后我已经在浏览器开发者控制台中运行了它.在那里,我可以阅读有关CORS的错误的说明.在api服务器上设置cors之后,它就可以工作了.

Then I have run it in browser dev console. There I could read description of the error about CORS. After setting cors on the api server, it worked.

您必须将fetch命令粘贴到起源相同的开发者控制台中,而并非偶然,例如从stackoverflow打开它.

You have to paste the fetch command into the dev console of the same origin and NOT accidentally e.g. open it from stackoverflow.

这篇关于是什么导致Chrome在本地主机上的服务器上针对缓存内容提供net :: ERR_FAILED?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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