Javascript 角度PWA重定向到错误的文件

Javascript 角度PWA重定向到错误的文件,javascript,angular,typescript,progressive-web-apps,Javascript,Angular,Typescript,Progressive Web Apps,我有一个Angular(v.10)应用程序,它使用PWA(v.0.901.15),我将我的索引页面设置为index.jsp文件。该文件不包含任何strage,我只是将index.html重命名为index.jsp,并替换项目中出现的内容 但是,从服务器打开我的应用程序有时会失败,因为我没有显示index.jsp文件,而是重定向到ngsw-worker.js或ngsw.json?ngsw cache bust=0.6858460076574093文件。这种行为似乎是随机的 我的PWA配置很简单:在

我有一个Angular(v.10)应用程序,它使用PWA(v.0.901.15),我将我的索引页面设置为index.jsp文件。该文件不包含任何strage,我只是将index.html重命名为index.jsp,并替换项目中出现的内容

但是,从服务器打开我的应用程序有时会失败,因为我没有显示index.jsp文件,而是重定向到ngsw-worker.js或ngsw.json?ngsw cache bust=0.6858460076574093文件。这种行为似乎是随机的

我的PWA配置很简单:在AppModule.ts文件中,我有:

ServiceWorkerModule.register('ngsw-worker.js', { enabled: environment.production, registrationStrategy: 'registerImmediately' })
我的ngsw-config.json如下所示:

{
 "$schema": "./node_modules/@angular/service-worker/config/schema.json",
  "index": "/index.jsp",
  "assetGroups": [
    {
      "name": "app",
      "installMode": "prefetch",
      "resources": {
        "files": [
          "/assets/icons/icon-72x72.png",
          "/index.jsp",
          "/manifest.webmanifest",
          "/*.css",
          "/*.js",
          "https://fonts.googleapis.com/icon?family=Material+Icons",
          "https://fonts.googleapis.com/css?family=Roboto:300,400,500&display=swap"
        ]
      }
    },
    {
      "name": "assets",
      "installMode": "lazy",
      "updateMode": "prefetch",
      "resources": {
        "files": [
          "/assets/**",
          "/*.(eot|svg|cur|jpg|png|webp|gif|otf|ttf|woff|woff2|ani)"
        ]
      }
    },
    {
      "name": "tiles",
      "installMode": "lazy",
      "updateMode": "prefetch",
      "resources": {
        "urls": [
          "https://c.tile.openstreetmap.org/*"
        ]
      }
    }
  ],
  "dataGroups": [
    {
      "name": "rest-get",
      "urls": [
        "/**"
      ],
      "cacheConfig": {
        "strategy": "freshness",
        "maxSize": 50,
        "maxAge": "1d",
        "timeout": "5s"
      }
    }
  ]
}
这是index.jsp

<!doctype html>
<html lang="it">

<head>
    <meta charset="utf-8">
    <title>MyApp</title>
    <base href="/">

    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate">
    <meta http-equiv="Pragma" content="no-cache">
    <meta http-equiv="Expires" content="0">

    <link href="https://fonts.googleapis.com/css?family=Roboto:300,400,500&amp;display=swap" rel="stylesheet">
    <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
    <link rel="manifest" href="manifest.webmanifest" crossorigin="use-credentials">
    <meta name="theme-color" content="#1976d2">

  <link rel="icon" type="image/x-icon" href="favicon.ico" />
</head>

<body class="mat-typography bct-theme">
    <app-root></app-root>
    <noscript>Please enable JavaScript to continue using this application.</noscript>
</body>

</html>

MyApp
请启用JavaScript以继续使用此应用程序。