排除来自角度PWA的后端呼叫-服务人员

时间:2019-12-20 16:09:21

标签: angular progressive-web-apps angular-service-worker

我在我的角度应用程序中添加了pwa模块,但我不想缓存后端请求。我有以下  ngsw-config.json文件:

{
  "$schema": "./node_modules/@angular/service-worker/config/schema.json",
  "index": "/index.html",
  "dataGroups":
  [
    {
      "name": "api",
      "urls": ["https://mydomain/api/**"],
      "cacheConfig": {
        "maxSize": 0,
        "maxAge": "0u",
        "strategy": "freshness"
      }
    }
  ],
  "assetGroups": [
    {
      "name": "app",
      "installMode": "prefetch",
      "resources": {
        "files": [
          "/favicon.ico",
          "/index.html",
          "/*.css",
          "/*.js"
        ]
      }
    }, {
      "name": "assets",
      "installMode": "lazy",
      "updateMode": "prefetch",
      "resources": {
        "files": [
          "/assets/**",
          "/*.(eot|svg|cur|jpg|png|webp|gif|otf|ttf|woff|woff2|ani)"
        ]
      }
    }
  ]
}

我添加了dataGroups来忽略对所有/ api端点的调用,但是仍然缓存了这些请求。您能帮我弄清楚我对ngsw-config.json配置错误吗?

0 个答案:

没有答案