You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[ ] Regression (a behavior that used to work and stopped working in a new release)
[x] Bug report
[ ] Performance issue
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question
[ ] Other... Please describe:
Current behavior
when where is a resources in assets directory, and filename includes space " ", the @angular/pwa service worker can't cache it correctly.
Expected behavior
Minimal reproduction of the problem with instructions
ng add @angular/pwa
put an image named "a b.jpg" in assets
reference it in html
ng build --prod
open it in browser
enable offline mode in chrome devtools
refresh page
it will got a 504.
What is the motivation / use case for changing the behavior?
Environment
Angular version: X.Y.Z
Browser:
- [x] Chrome (desktop) version 68
- [ ] Chrome (Android) version XX
- [ ] Chrome (iOS) version XX
- [ ] Firefox version XX
- [ ] Safari (desktop) version XX
- [ ] Safari (iOS) version XX
- [ ] IE version XX
- [ ] Edge version XX
For Tooling issues:
- Node version: XX
- Platform:
Others:
This is a valid issue. The problem is that in the config generator, we process the file paths as reported by the filesystem, but the URL can differ (due to URI encoding).
So, the generated ngsw.json has an entry for /assets/a b.png, but the SW tries to match it with a request for /assets/a%20b.png and fails.
Just a shoutout that this is still a problem.
Our team fixed it by using this in package.json: "build:prod": "ng build --prod && npm run fix-ngsw", "fix-ngsw": "shx sed -i \"([\\w\\)])( )([\\w\\(])\" '$1%20$3' dist/**/ngsw.json"
Activity
gkalpak commentedon Aug 13, 2018
This is a valid issue. The problem is that in the config generator, we process the file paths as reported by the filesystem, but the URL can differ (due to URI encoding).
So, the generated
ngsw.jsonhas an entry for/assets/a b.png, but the SW tries to match it with a request for/assets/a%20b.pngand fails.fix(service-worker): correctly handle requests with escape characters
Ruud-cb commentedon Oct 28, 2020
Just a shoutout that this is still a problem.
Our team fixed it by using this in package.json:
"build:prod": "ng build --prod && npm run fix-ngsw","fix-ngsw": "shx sed -i \"([\\w\\)])( )([\\w\\(])\" '$1%20$3' dist/**/ngsw.json"Using this and this dependency
JeanMeche commentedon Aug 29, 2025
with #63364 we've announced that the service-worker package in now in maintenance mode and will not receive feature PRs and feature requests.
The message is also visible here: https://angular.dev/ecosystem/service-workers
angular-automatic-lock-bot commentedon Sep 29, 2025
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.