部署后Angular Service Worker提取错误

时间:2019-01-04 14:20:20

标签: angular angular-service-worker

我将Angular 7与Angular Service Worker结合使用。但是,在部署了新的应用程序版本之后,大多数情况下都会出现此错误,并且应用程序仅在刷新后才能运行:

The FetchEvent for "https://example.com/runtime.e0d7b28adf942e10148b.js" resulted in a network error response: the promise was rejected.
ngsw-worker.js:589 Uncaught (in promise) Error: Response not Ok (fetchAndCacheOnce): request for https://example.com/runtime.e0d7b28adf942e10148b.js returned response 504 Gateway Timeout
at PrefetchAssetGroup.<anonymous> (ngsw-worker.js:589)
at Generator.next (<anonymous>)
at fulfilled (ngsw-worker.js:312)
runtime.e0d7b28adf942e10148b.js:1 Failed to load resource: net::ERR_FAILED

这是ngsw-config.json配置:

 "index": "/index.html",
  "assetGroups": [{
    "name": "app",
    "installMode": "prefetch",
    "resources": {
      "files": [
        "/favicon.ico",
        "/index.html",
        "/*.css",
        "/*.js"
      ]
    }
  }, {
    "name": "assets",
    "installMode": "lazy",
    "updateMode": "prefetch",
    "resources": {
      "files": [
        "/assets/**"
      ]
    }
  }]

当前,还启用了HTTP缓存,这可能会引起问题吗?

0 个答案:

没有答案