Skip to content

pwa can't cache resource with space in url #25443

Closed as not planned
Closed as not planned

Description

@zh99998

I'm submitting a...


[ ] 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:

Activity

  1. added this to the needsTriage milestone on Aug 13, 2018
  2. modified the milestones: needsTriage, Backlog on Aug 13, 2018
  3. gkalpak commented on Aug 13, 2018

    @gkalpak
    Member

    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.

  4. added
    P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgent
    and removed on Oct 1, 2020
  5. Ruud-cb commented on Oct 28, 2020

    @Ruud-cb

    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

  6. JeanMeche commented on Aug 29, 2025

    @JeanMeche
    Member

    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

  7. angular-automatic-lock-bot commented on Sep 29, 2025

    @angular-automatic-lock-bot

    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.

  8. locked and limited conversation to collaborators on Sep 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgentarea: service-workerIssues related to the @angular/service-worker packageeffort1: hoursfreq1: lowstate: confirmedtype: bug/fix

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions