angularjs - Angular $http 回调不适用于 Chrome 中的 HTTP 304

标签 angularjs google-chrome http cache-control

我遇到了 Angular 1.5 的问题,但我无法通过 Google 找到类似的问题。一个可喜的变化,这个问题在 IE 中不存在,它只发生在最新版本的 Chrome 中。

当我使用 JSON API 并连续两次发送相同的 GET 请求时,第一个请求返回 200 OK,第二个请求返回 304 未修改。我正在使用 'Cache-Control': 'no-cache' 来模拟我们的(生成的)API 客户端如何执行请求。在缓存控制启用 的情况下,两个请求都被正确执行(请参阅 F12)并且程序终止。在缓存控制禁用的情况下,两个请求都可以正确执行 (F12),但程序不会终止。

这是 Chrome 中的错误,还是 Angular 的 $http 中的错误,还是我遗漏了一些关键细节?

Minimal example on JsFiddle

输出:

Hi
Sending request 1 to http://jsonplaceholder.typicode.com/posts/1...
Success 1!
Resolved 1!
Sending request 2 to http://jsonplaceholder.typicode.com/posts/1...

最佳答案

在 Google Chrome 更新后修复。

关于angularjs - Angular $http 回调不适用于 Chrome 中的 HTTP 304,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39369525/

相关文章:

javascript - Angularjs - 如何单元测试表单验证

javascript - 如何自动/动态导入自己的 angularjs javascript 文件?

javascript - 如何设置 Protractor 配置以在 FireFox 上运行并启用 CORS

swift - 尝试访问 Alamofire 中的错误代码

c# - WCF 服务不返回 GET 方法不允许的方法

javascript - 重新定义对象字段或数组元素而不是分配对其他对象的引用是否有任何值(value)

angularjs - ionic 列表 : swipe to remove?

javascript - 在谷歌浏览器中,getBoundingClientRect().x 未定义

html - 使用 Google chrome 下载/打开 .csv 文件,它将 .csv 文件的扩展名更改为 .xls

java - 使用 Angular 客户端访问休息端点时的 CORS 问题 - 允许跨源