2

我想从服务工作者缓存中排除清单文件,因为它是由 Web 函数动态创建的。

<link rel="manifest" href="/.additional/resources/manifest>

我试图通过添加到这里提到的 dataGroup、assetGroups 和 navigationUrls 来排除它:

Angular 5 和 Service Worker:如何从 ngsw-config.json 中排除特定路径

但不幸的是,没有任何效果,文件仍然由 ngsw 提供。请在此处找到服务人员代码:

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

我也已经尝试绕过 url 参数和它的工作人员,但我宁愿从缓存中排除:

<link rel="manifest" href="/.additional/resources/manifest?ngsw-bypass=true">

先感谢您!

4

0 回答 0