Angularjs应用程序在从firebase托管服务器检索html模板时不处理304响应

ado*_*srs 8 http-status-code-304 angularjs firebase angular-ui-router firebase-hosting

当我的服务器以状态代码304响应时,我有一些用户无法访问我的angularjs应用程序上的某些模板.Angularjs正在记录[$compile:tpload],如下所示,视图不会显示给用户.因此,某种角度不会从缓存中获取视图.问题似乎非常间歇性地发生,并且在干净的浏览器缓存+页面刷新之后页面再次开始正常工作.

我用ui-router v0.3.2运行Angularjs v1.6.6并且我在firebase托管上托管我的静态文件.它是在最新版本上修复的吗?否则,我该如何处理这个案子呢?

[$ compile:tpload] http://errors.angularjs.org/1.6.6/$compile/tpload?p0=%2Fjs%2Ftemplate1%template1.html&p1=304

可能是未处理的拒绝:{"data":"","status":304,"config":{"method":"GET","transformRequest":[null],"transformResponse":[null],"jsonpCallbackParam" : "回调", "缓存":{}, "头":{ "接受": "text/html的"}, "URL": "/ p/p.html"}, "状态文本": ""," xhrStatus ":" 完成"}


使用LogRocket捕获请求/响应

URL: "https://url.com/js/p/a/template.html"
method: "GET"
status: 304
duration: "00:00.061"

REQUEST
headers
  Accept: "application/json, text/plain, */*"
body: null
credentials: ""
mode: ""
referrer: ""


RESPONSE
headers
  cache-control: "max-age=3600"
  date: "Sat, 15 Sep 2018 20:03:12 GMT"
  etag: ""f166a7577a895x3f7dcc5accae97dcba""
  expires: "Sat, 15 Sep 2018 17:45:33 GMT"
  vary: "Accept-Encoding"
  via: "1.1 varnish"
  x-cache: "HIT"
  x-cache-hits: "1"
  x-served-by: "cache-bma1622-BMA"
  x-timer: "S1537041792.121483,VS0,VE1"

body: ""
Run Code Online (Sandbox Code Playgroud)

小智 -1

您可以尝试将其添加到您的app.config函数中。

app.config(['$qProvider', function ($qProvider) {
    $qProvider.errorOnUnhandledRejections(false);
}]);
Run Code Online (Sandbox Code Playgroud)

在其他情况下,人们看到这个“错误”,他们使用该代码作为解决方法来修复它。