I am currently in the final phases of creating a PWA using Angular's 
Service Worker package. The web site I am building currently has a home 
page with 50, dynamic-template images from an external API (eg: 
http://blah.com/v2/{{id}}/icon.png). The current service worker set up 
caches these images and uses up the browsers storage. Every day these 
images change and so it does not pay to cache them plus, there are 50 so it 
takes up A LOT of space in the browser. Is there a way to prevent images 
from the external source from being cached?

The following is the current set up of my ngsw-config.json file:

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




The random /v2/ in the dataGroups section was my last of many failed 
attempts to fix this problem.

I even removed all image file endings from the assetGroups section, but 
that did not work either.

-- 
You received this message because you are subscribed to the Google Groups 
"Angular and AngularJS discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to angular+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/angular/f69f2ee0-1466-4c0f-ac8b-270b30956ae1o%40googlegroups.com.

Reply via email to