-
Notifications
You must be signed in to change notification settings - Fork 27.1k
@angular/pwa doesn't clean up previous service worker version's cached content #41728
Description
🐞 bug report
Affected Package
The issue is caused by package @angular/pwa
Is this a regression?
No
Description
I am noticing that with every new version of my application the cache size grows considerably because the Angular Service worker is keeping the previous versions of the application in cache? This means that everytime you release a new version of your application, the new version's resources will be cached for offline use (the expected behavior). However, all of the cached content (scripts, css, HTML, etc) from the previous versions of the application are still stored in cache. This means that the application's cache will grow exponentially with every release of your application.
🔬 Minimal Reproduction
- Setup new CLI project ng new my-pwa-app
- Add PWA support ng add @angular/pwa --project my-pwa-app
- Build production version of application and run locally (observe cache size)
- Make small (non-functional) change to the application (just to change file hashing) - representing a new version of your application being deployed.
- Build production version of the application and run locally again (NOTE: the cache size will be double what it was before). Repeat steps 4 and 5 and this behavior will continue (cache size will continue to grow, because it is holding onto the previous version's cached files).
Application cache storage (same content, different version):
Version 1: 12.2 MB
Version 2: 23.5 MB
Version 3: 32.9 MB
...etc.
