feat(service-worker): Support ignoring specific URLs
See original GitHub issue🚀 feature request
Relevant Package
This feature request is for @angular/service-worker
Description
While forcing the SW to ignore specific URL is now possible adding http header ngsw-bypass
or ngsw-bypass=true
as query param, it’s not possible to specify some URLs to be ignored. This would be very useful when dealing with SDKs like Firestore, that don’t allow to edit the http requests.
Describe the solution you’d like
As discussed in #21191 some workarounds are possible : #21191 (Comment) or 21192 (Comment).
Second comment also contains a suggestion on how to modify SW in order to implement the requested feature. This would mean accepting messages to allow to set a list of URLs to ignore.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:11
- Comments:10 (8 by maintainers)
Top Results From Across the Web
feat(service-worker): Support ignoring specific URLs (e.g. for ...
I found a fairly simple workaround if you want your SW to completely "ignore" a specific path (for example we had a few...
Read more >Setting service worker to exclude certain urls only
I have nginx setup to serve /blog/ and it works fine if someone visits /blog/ without visiting the react app first. However because...
Read more >API Simulator feat. Service Worker - Paul Bakaus' blog
API Simulator allows you to setup any number of static routes (URLs) on the host it runs on, allowing you to test a...
Read more >Service Workers and Progressive Web Apps (PWA) - InformIT
An introduction to service workers and how to use them to enable cool background processing in your web app.
Read more >Using Service Workers - Web APIs | MDN
A service worker functions like a proxy server, allowing you to modify requests and responses replacing them with items from its own cache....
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 Free
Top 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
WRT https://github.com/angular/angular/issues/30195#issuecomment-492373860: Although there are no immediate plans, we are considering/investigating ways to make the SW more flexible and extensible. It will take a significant refactoring, though, so not going to happen overnight 😁
WRT https://github.com/angular/angular/issues/30195#issuecomment-492383256: Anything involving
ngsw-config.json
is async (i.e. the SW needs to retrieve the config from theCache
) and thus can’t be used to make a sync decision inonFetch
.Another idea:
Add property in
ngsw-config.json
pointing to a.js
file containing app-specific code to be executed in the serviceworker (onFetch event). That would be a simple but powerful addition that keeps the SW script independent of the app version, and does not involve code evaluation on the fly.