ngsw-worker.js cache files which are not in dataGroups
See original GitHub issueWhich @angular/* package(s) are the source of the bug?
service-worker
Is this a regression?
No
Description
Following is my ngsw-config.json
{
"$schema": "./node_modules/@angular/service-worker/config/schema.json",
"index": "/index.html",
"appData": {
"version": "1.0.11"
},
"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|jpg|png|webp|gif|otf|ttf|woff|woff2|ani)"
]
}
}
],
"dataGroups": [
{
"name": "s3",
"version": 2,
"urls": [
"https://s3.${BASE_DOMAIN}/**/*.7z",
"https://s3.${BASE_DOMAIN}/**/*.csv",
"https://s3.${BASE_DOMAIN}/**/*.gif",
"https://s3.${BASE_DOMAIN}/**/*.midi",
"https://s3.${BASE_DOMAIN}/**/*.png",
"https://s3.${BASE_DOMAIN}/**/*.tif",
"https://s3.${BASE_DOMAIN}/**/*.zip",
"https://s3.${BASE_DOMAIN}/**/*.avi",
"https://s3.${BASE_DOMAIN}/**/*.doc",
"https://s3.${BASE_DOMAIN}/**/*.gz",
"https://s3.${BASE_DOMAIN}/**/*.mkv",
"https://s3.${BASE_DOMAIN}/**/*.ppt",
"https://s3.${BASE_DOMAIN}/**/*.tiff",
"https://s3.${BASE_DOMAIN}/**/*.zst",
"https://s3.${BASE_DOMAIN}/**/*.avif",
"https://s3.${BASE_DOMAIN}/**/*.docx",
"https://s3.${BASE_DOMAIN}/**/*.ico",
"https://s3.${BASE_DOMAIN}/**/*.mp3",
"https://s3.${BASE_DOMAIN}/**/*.pptx",
"https://s3.${BASE_DOMAIN}/**/*.ttf",
"https://s3.${BASE_DOMAIN}/**/*.apk",
"https://s3.${BASE_DOMAIN}/**/*.dmg",
"https://s3.${BASE_DOMAIN}/**/*.iso",
"https://s3.${BASE_DOMAIN}/**/*.mp4",
"https://s3.${BASE_DOMAIN}/**/*.ps",
"https://s3.${BASE_DOMAIN}/**/*.webm",
"https://s3.${BASE_DOMAIN}/**/*.bin",
"https://s3.${BASE_DOMAIN}/**/*.ejs",
"https://s3.${BASE_DOMAIN}/**/*.jar",
"https://s3.${BASE_DOMAIN}/**/*.ogg",
"https://s3.${BASE_DOMAIN}/**/*.rar",
"https://s3.${BASE_DOMAIN}/**/*.webp",
"https://s3.${BASE_DOMAIN}/**/*.bmp",
"https://s3.${BASE_DOMAIN}/**/*.eot",
"https://s3.${BASE_DOMAIN}/**/*.jpg",
"https://s3.${BASE_DOMAIN}/**/*.otf",
"https://s3.${BASE_DOMAIN}/**/*.svg",
"https://s3.${BASE_DOMAIN}/**/*.woff",
"https://s3.${BASE_DOMAIN}/**/*.bz2",
"https://s3.${BASE_DOMAIN}/**/*.eps",
"https://s3.${BASE_DOMAIN}/**/*.jpeg",
"https://s3.${BASE_DOMAIN}/**/*.pdf",
"https://s3.${BASE_DOMAIN}/**/*.svgz",
"https://s3.${BASE_DOMAIN}/**/*.woff2",
"https://s3.${BASE_DOMAIN}/**/*.class",
"https://s3.${BASE_DOMAIN}/**/*.exe",
"https://s3.${BASE_DOMAIN}/**/*.js",
"https://s3.${BASE_DOMAIN}/**/*.pict",
"https://s3.${BASE_DOMAIN}/**/*.swf",
"https://s3.${BASE_DOMAIN}/**/*.xls",
"https://s3.${BASE_DOMAIN}/**/*.css",
"https://s3.${BASE_DOMAIN}/**/*.flac",
"https://s3.${BASE_DOMAIN}/**/*.mid",
"https://s3.${BASE_DOMAIN}/**/*.pls",
"https://s3.${BASE_DOMAIN}/**/*.tar",
"https://s3.${BASE_DOMAIN}/**/*.xlsx"
],
"cacheConfig": {
"maxSize": 100,
"maxAge": "4h"
}
}
]
}
You can see that *.json files shouldn’t be cached. There is no entry for it in dataGroups. But I found my JSON files cached under:
ngsw:/:2:data:dynamic:s3:cache - https://mydomain.com
Please provide a link to a minimal reproduction of the bug
No
Please provide the exception or error you saw
You can see that *.json files shouldn't be cached. But I found my JSON files cached under:
ngsw:/:2:data:dynamic:s3:cache - https://mydomain.com
### Please provide the environment you discovered this bug in (run `ng version`)
```true
Angular CLI: 11.2.18
Node: 16.13.1
OS: win32 x64
Angular: 11.2.14
... animations, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, router
... service-worker
Ivy Workspace: Yes
Package Version
---------------------------------------------------------
@angular-devkit/architect 0.1102.18
@angular-devkit/build-angular 0.1102.18
@angular-devkit/core 11.2.18
@angular-devkit/schematics 11.2.18
@angular/cli 11.2.18
@schematics/angular 11.2.18
@schematics/update 0.1102.18
rxjs 6.6.7
typescript 4.0.8
Anything else?
No
Issue Analytics
- State:
- Created 2 years ago
- Comments:13 (8 by maintainers)
Top Results From Across the Web
Service worker configuration - Angular
The ngsw-config.json configuration file specifies which files and data URLs the Angular service worker should cache and how it should update the cached...
Read more >Cache asset via freshness in Angular 6 Service Worker
After that I've tried to include it again via dataGroups and setting the strategy to freshness but it seems that the asset won't...
Read more >Angular Service Worker - Step-By-Step Guide
The Angular Service Worker can cache all sorts of content in the browser Cache Storage. This is a Javascript-based key/value caching mechanism ...
Read more >How to Work with Service Workers In Angular 5
In the case of Network First, the return data received via the network is considered top priority and the cache is used in...
Read more >Automatic Progressive Web Apps
3. Register NGSW for your app. 4. Create configuration file ... ServiceWorkerModule.register('/ngsw-worker.js', ... Runtime caching. dataGroups.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Being more explicit would work too. We could keep the string form (defaulting to
glob
) for backwards compatibility and also support the more explicit forms (withtype
). We would need to increment theconfigVersion
in the config generator, so that older ServiceWorkers know not to try and parse the new format.BTW, we would need to apply this to assetGroups > resources, dataGroupd > urls and navigationUrls. And we also need a strategy for handling negative patterns. Currently, a glob pattern is considered negative if it starts with
!
.This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.