New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(service-worker): add support for ignoring specific URLs #23025
Conversation
You can preview 3e4e220 at https://pr23025-3e4e220.ngbuilds.io/. |
TODOs
TODECIDEs
cc @alxhub |
Nice work! I don't think we can support not handling such requests at all (not calling This is because we could possibly be in a mode where we were just started, and need to fetch the manifest/etc from cache to figure out how to handle the request. Since this can only happen asynchronously and skipping |
Oh, I didn't know |
557ccf0
to
9e6edca
Compare
You can preview 9e6edca at https://pr23025-9e6edca.ngbuilds.io/. |
b49b72d
to
7f2155e
Compare
Updated the public API (needs approval), fixed up tests and updated the SW Config guide. |
You can preview 7f2155e at https://pr23025-7f2155e.ngbuilds.io/. |
@coryrylan wrote (in #20404 (comment)): Would a list of regexes be more flexible? https://developers.google.com/web/tools/workbox/modules/workbox-build |
I would love to have regexp support (as stated in #23025 (comment) 😁). Things to consider:
@alxhub, WDYT? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm for public api changes
For future reference:
|
Normally, the ServiceWorker will redirect navigation requests that don't match any `asset` or `data` group to the specified index file. Yet, sometimes it is desirable to configure the SW to ignore specific URLs (even for navigation requests) and pass them through to the server. This commit adds support for specifying an optional `ignoredUrlPatterns` list in `ngsw-config.json`, which contains URLs or simple globs (currently only recognizing `*` and `**`). Requests matching these URLs or patterns will not be handled by the SW. Fixes angular#20404
7f2155e
to
6239dfb
Compare
You can preview 6239dfb at https://pr23025-6239dfb.ngbuilds.io/. |
The ServiceWorker will redirect navigation requests that don't match any `asset` or `data` group to the specified index file. The rules for a request to be classified as a navigation request are as follows: 1. Its `mode` must be `navigation`. 2. It must accept a `text/html` response. 3. Its URL must match certain criteria (see below). By default, a navigation request can have any URL except for: 1. URLs containing `__`. 2. URLs to files (i.e. containing a file extension in the last path segment). While thse rules are fine in many cases, sometimes it is desirable to configure different rules for the URLs of navigation requests (e.g. ignore specific URLs and pass them through to the server). This commit adds support for specifying an optional `navigationUrls` list in `ngsw-config.json`, which contains URLs or simple globs (currently only recognizing `!`, `*` and `**`). Only requests whose URLs match any of the positive URLs/patterns and none of the negative ones (i.e. URLs/patterns starting with `!`) will be considered navigation requests (and handled accordingly by the SW). (This is an alternative implementation to angular#23025.) Fixes angular#20404
The ServiceWorker will redirect navigation requests that don't match any `asset` or `data` group to the specified index file. The rules for a request to be classified as a navigation request are as follows: 1. Its `mode` must be `navigation`. 2. It must accept a `text/html` response. 3. Its URL must match certain criteria (see below). By default, a navigation request can have any URL except for: 1. URLs containing `__`. 2. URLs to files (i.e. containing a file extension in the last path segment). While thse rules are fine in many cases, sometimes it is desirable to configure different rules for the URLs of navigation requests (e.g. ignore specific URLs and pass them through to the server). This commit adds support for specifying an optional `navigationUrls` list in `ngsw-config.json`, which contains URLs or simple globs (currently only recognizing `!`, `*` and `**`). Only requests whose URLs match any of the positive URLs/patterns and none of the negative ones (i.e. URLs/patterns starting with `!`) will be considered navigation requests (and handled accordingly by the SW). (This is an alternative implementation to angular#23025.) Fixes angular#20404
The ServiceWorker will redirect navigation requests that don't match any `asset` or `data` group to the specified index file. The rules for a request to be classified as a navigation request are as follows: 1. Its `mode` must be `navigation`. 2. It must accept a `text/html` response. 3. Its URL must match certain criteria (see below). By default, a navigation request can have any URL except for: 1. URLs containing `__`. 2. URLs to files (i.e. containing a file extension in the last path segment). While these rules are fine in many cases, sometimes it is desirable to configure different rules for the URLs of navigation requests (e.g. ignore specific URLs and pass them through to the server). This commit adds support for specifying an optional `navigationUrls` list in `ngsw-config.json`, which contains URLs or simple globs (currently only recognizing `!`, `*` and `**`). Only requests whose URLs match any of the positive URLs/patterns and none of the negative ones (i.e. URLs/patterns starting with `!`) will be considered navigation requests (and handled accordingly by the SW). (This is an alternative implementation to angular#23025.) Fixes angular#20404
Alternative implementation (supporting both positive and negative patterns) in #23339. |
The ServiceWorker will redirect navigation requests that don't match any `asset` or `data` group to the specified index file. The rules for a request to be classified as a navigation request are as follows: 1. Its `mode` must be `navigation`. 2. It must accept a `text/html` response. 3. Its URL must match certain criteria (see below). By default, a navigation request can have any URL except for: 1. URLs containing `__`. 2. URLs to files (i.e. containing a file extension in the last path segment). While these rules are fine in many cases, sometimes it is desirable to configure different rules for the URLs of navigation requests (e.g. ignore specific URLs and pass them through to the server). This commit adds support for specifying an optional `navigationUrls` list in `ngsw-config.json`, which contains URLs or simple globs (currently only recognizing `!`, `*` and `**`). Only requests whose URLs match any of the positive URLs/patterns and none of the negative ones (i.e. URLs/patterns starting with `!`) will be considered navigation requests (and handled accordingly by the SW). (This is an alternative implementation to angular#23025.) Fixes angular#20404
…23339) The ServiceWorker will redirect navigation requests that don't match any `asset` or `data` group to the specified index file. The rules for a request to be classified as a navigation request are as follows: 1. Its `mode` must be `navigation`. 2. It must accept a `text/html` response. 3. Its URL must match certain criteria (see below). By default, a navigation request can have any URL except for: 1. URLs containing `__`. 2. URLs to files (i.e. containing a file extension in the last path segment). While these rules are fine in many cases, sometimes it is desirable to configure different rules for the URLs of navigation requests (e.g. ignore specific URLs and pass them through to the server). This commit adds support for specifying an optional `navigationUrls` list in `ngsw-config.json`, which contains URLs or simple globs (currently only recognizing `!`, `*` and `**`). Only requests whose URLs match any of the positive URLs/patterns and none of the negative ones (i.e. URLs/patterns starting with `!`) will be considered navigation requests (and handled accordingly by the SW). (This is an alternative implementation to #23025.) Fixes #20404 PR Close #23339
superseded by #23339 |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
PR Checklist
PR Type
What is the current behavior?
The ServiceWorker will redirect navigation requests that don't match any
asset
ordata
group to the specified index file. Yet, sometimes it is desirable to configure the SW to ignore specific URLs (even for navigation requests) and pass them through to the server.Issue Number: #20404
What is the new behavior?
This commit adds support for specifying an optional
ignoredUrlPatterns
list inngsw-config.json
, which contains URLs or simple globs (currently only recognizing*
and**
). Requests matching these URLs or patterns will not be handled by the SW.Does this PR introduce a breaking change?
Other information
Fixes #20404.