Angular 如何防止服务工作者从api进行双重调用?

Angular 如何防止服务工作者从api进行双重调用?,angular,typescript,progressive-web-apps,service-worker,Angular,Typescript,Progressive Web Apps,Service Worker,我有一个角度应用程序,我只想我的静态文件将被缓存,而不是api调用,因为有时它会发出两次调用。我如何防止这种情况 我的ngsw配置: { "$schema": "./node_modules/@angular/service-worker/config/schema.json", "index": "/index.html", "assetGroups": [

我有一个角度应用程序,我只想我的静态文件将被缓存,而不是api调用,因为有时它会发出两次调用。我如何防止这种情况

我的ngsw配置:

{
    "$schema": "./node_modules/@angular/service-worker/config/schema.json",
    "index": "/index.html",
    "assetGroups": [
      {
        "name": "app",
        "installMode": "prefetch",
        "resources": {
          "files": [
            "/favicon.ico",
            "/index.html",
            "/manifest.webmanifest",
            "/*.css",
            "/*.js"
          ]
        }
      }, {
        "name": "assets",
        "installMode": "lazy",
        "updateMode": "prefetch",
        "resources": {
          "files": [
            "/assets/**",
            "/*.(eot|svg|cur|jpg|png|webp|gif|otf|ttf|woff|woff2|ani)"
          ]
        }
      }
    ]
  }
有时,当api调用(生成GET)时,后端会收到两个调用,一个来自服务工作者,另一个正常。如何防止这种情况发生?

你说的“后端接到2个电话”是什么意思?您正在查看服务器日志并看到重复的请求?