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
{{ message }}
Repository navigation
Commit 6239dfb
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: aio/content/guide/service-worker-config.md
+17-9Lines changed: 17 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,3 @@
1
-
{@a glob}
2
-
3
1
# Service worker configuration
4
2
5
3
#### Prerequisites
@@ -9,9 +7,9 @@ A basic understanding of the following:
9
7
10
8
<hr />
11
9
12
-
The `src/ngsw-config.json` configuration file specifies which files and data URLs the Angular
13
-
service worker should cache and how it should update the cached files and data. The
14
-
CLI processes the configuration file during `ng build --prod`. Manually, you can process
10
+
The `src/ngsw-config.json` configuration file specifies which files and data URLs the Angular
11
+
service worker should cache and how it should update the cached files and data. The
12
+
CLI processes the configuration file during `ng build --prod`. Manually, you can process
15
13
it with the `ngsw-config` tool:
16
14
17
15
```sh
@@ -32,7 +30,7 @@ Example patterns:
32
30
*`/*.html` specifies only HTML files in the root.
33
31
*`!/**/*.map` exclude all sourcemaps.
34
32
35
-
Each section of the configuration file is described below.
33
+
Each section of the configuration file is described below.
36
34
37
35
## `appData`
38
36
@@ -43,6 +41,17 @@ The `SwUpdate` service includes that data in the update notifications. Many apps
43
41
44
42
Specifies the file that serves as the index page to satisfy navigation requests. Usually this is `/index.html`.
45
43
44
+
## `ignoredUrlPatterns`
45
+
46
+
This section enables you to specify URLs that will not be handled by the service worker. The service
47
+
worker will forward matching requests to the server and neither try to retrieve responses from the
48
+
cache nor serve the index page (even for navigation requests). This is useful for routes that are
49
+
not part of the Angular app, but should always be handled by the server.
50
+
51
+
This field contains an array of URLs and glob-like URL patterns that will be matched at runtime.
52
+
53
+
**Note**: Currently, negative patterns (i.e. patterns beginning with `!`) are _not_ supported.
54
+
46
55
## `assetGroups`
47
56
48
57
*Assets* are resources that are part of the app version that update along with the app. They can include resources loaded from the page's origin as well as third-party resources loaded from CDNs and other external URLs. As not all such external URLs may be known at build time, URL patterns can be matched.
@@ -92,7 +101,7 @@ The `installMode` determines how these resources are initially cached. The `inst
92
101
93
102
For resources already in the cache, the `updateMode` determines the caching behavior when a new version of the app is discovered. Any resources in the group that have changed since the previous version are updated in accordance with `updateMode`.
94
103
95
-
*`prefetch` tells the service worker to download and cache the changed resources immediately.
104
+
*`prefetch` tells the service worker to download and cache the changed resources immediately.
96
105
97
106
*`lazy` tells the service worker to not cache those resources. Instead, it treats them as unrequested and waits until they're requested again before updating them. An `updateMode` of `lazy` is only valid if the `installMode` is also `lazy`.
98
107
@@ -135,7 +144,7 @@ A list of URL patterns. URLs that match these patterns will be cached according
135
144
### `version`
136
145
Occasionally APIs change formats in a way that is not backward-compatible. A new version of the app may not be compatible with the old API format and thus may not be compatible with existing cached resources from that API.
137
146
138
-
`version` provides a mechanism to indicate that the resources being cached have been updated in a backwards-incompatible way, and that the old cache entries—those from previous versions—should be discarded.
147
+
`version` provides a mechanism to indicate that the resources being cached have been updated in a backwards-incompatible way, and that the old cache entries—those from previous versions—should be discarded.
139
148
140
149
`version` is an integer field and defaults to `0`.
141
150
@@ -166,4 +175,3 @@ The Angular service worker can use either of two caching strategies for data res
166
175
*`performance`, the default, optimizes for responses that are as fast as possible. If a resource exists in the cache, the cached version is used. This allows for some staleness, depending on the `maxAge`, in exchange for better performance. This is suitable for resources that don't change often; for example, user avatar images.
167
176
168
177
*`freshness` optimizes for currency of data, preferentially fetching requested data from the network. Only if the network times out, according to `timeout`, does the request fall back to the cache. This is useful for resources that change frequently; for example, account balances.
0 commit comments