Zahidur Rahman
Zahidur Rahman

Reputation: 1718

External Image cache by Angular Service Worker

I have a image source from external example like as https://cdn.myserver.com.background.jpg , i can not able to cache it by service worker , when image comes from assets folder it works, but external image link not cache.

Please give me any suggestion. thanks

{
  "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/**"
        ]
      }
    }
  ],
  "dataGroups": [
    {
      "name": "api-performance",
      "urls": [
        "http://127.0.0.1:3000/**"
      ],
      "cacheConfig": {
        "maxSize": 100,
        "maxAge": "3d",
        "strategy": "performance"
      }
    }
  ]
}

Upvotes: 1

Views: 2257

Answers (1)

syam
syam

Reputation: 61

you can add that particular url to the

 {
      "name": "assets",
      "installMode": "lazy",
      "updateMode": "prefetch",
      "resources": {
        "files": [
          "/assets/**"
        ],
         "urls": [
"https://cdn.myserver.com.background.jpg" ]
      }
    }

Upvotes: 4

Related Questions