zoukankan      html  css  js  c++  java
  • [Angular] Performance Caching Policy

    If you want to cache API response by using angular service-worker, you can do it in:

    src/ngsw-config.json:

    {
      "index": "/index.html",
      "assetGroups": [{
        "name": "app",
        "installMode": "prefetch",
        "resources": {
          "files": [
            "/favicon.ico",
            "/index.html"
          ],
          "versionedFiles": [
            "/*.bundle.css",
            "/*.bundle.js",
            "/*.chunk.js"
          ]
        }
      }, {
        "name": "assets",
        "installMode": "lazy",
        "updateMode": "prefetch",
        "resources": {
          "files": [
            "/assets/**"
          ]
        }
      }],
      // cache for API data
      "dataGroups": [
        {
          "name": "lessons-api",
          "urls": [
            "/api/lessons"
          ],
          "cacheConfig": {
            "strategy": "performance", // cache first, network last
            "maxAge": "1d",
            "maxSize": 100
          }
        }
      ]
    }
  • 相关阅读:
    第九周作业
    第八周作业
    第七周作业
    作业2
    作业1
    2019春总结作业
    第十四周总结
    十二周编程总结
    十一周编程总结
    第十周作业
  • 原文地址:https://www.cnblogs.com/Answer1215/p/8879040.html
Copyright © 2011-2022 走看看