UNPKG

10.6 kBJSONView Raw
1{
2 "$schema": "https://json-schema.org/draft-07/schema",
3 "type": "object",
4 "properties": {
5 "$schema": {
6 "type": "string"
7 },
8 "appData": {
9 "type": "object",
10 "description": "This section enables you to pass any data you want that describes this particular version of the app. The SwUpdate service includes that data in the update notifications. Many apps use this section to provide additional information for the display of UI popups, notifying users of the available update."
11 },
12 "index": {
13 "type": "string",
14 "description": "Specifies the file that serves as the index page to satisfy navigation requests. Usually this is '/index.html'."
15 },
16 "assetGroups": {
17 "type": "array",
18 "description": "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.",
19 "items": {
20 "type": "object",
21 "properties": {
22 "name": {
23 "type": "string",
24 "description": "It identifies this particular group of assets between versions of the configuration."
25 },
26 "installMode": {
27 "enum": [
28 "prefetch",
29 "lazy"
30 ],
31 "default": "prefetch",
32 "description": "Determines how the resources are initially cached. 'prefetch' tells the Angular service worker to fetch every single listed resource while it's caching the current version of the app. This is bandwidth-intensive but ensures resources are available whenever they're requested, even if the browser is currently offline. 'lazy' does not cache any of the resources up front. Instead, the Angular service worker only caches resources for which it receives requests. This is an on-demand caching mode. Resources that are never requested will not be cached. This is useful for things like images at different resolutions, so the service worker only caches the correct assets for the particular screen and orientation."
33 },
34 "updateMode": {
35 "enum": [
36 "prefetch",
37 "lazy"
38 ],
39 "description": "For resources already in the cache, 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'. 'prefetch' tells the service worker to download and cache the changed resources immediately. '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. Defaults to the value `installMode` is set to."
40 },
41 "resources": {
42 "type": "object",
43 "description": "This section describes the resources to cache.",
44 "properties": {
45 "files": {
46 "type": "array",
47 "description": "Lists patterns that match files in the distribution directory. These can be single files or glob-like patterns that match a number of files.",
48 "items": {
49 "type": "string"
50 },
51 "uniqueItems": true
52 },
53 "urls": {
54 "type": "array",
55 "description": "Includes both URLs and URL patterns that will be matched at runtime. These resources are not fetched directly and do not have content hashes, but they will be cached according to their HTTP headers. This is most useful for CDNs such as the Google Fonts service. (Negative glob patterns are not supported and '?' will be matched literally; i.e. it will not match any character other than '?'.)",
56 "items": {
57 "type": "string"
58 },
59 "uniqueItems": true
60 }
61 },
62 "additionalProperties": false
63 },
64 "cacheQueryOptions" : {
65 "type": "object",
66 "description": "Provide options that are passed to Cache#match.",
67 "properties" : {
68 "ignoreSearch": {
69 "type": "boolean",
70 "description": "Whether to ignore the query string in the URL."
71 }
72 },
73 "additionalProperties": false
74 }
75 },
76 "required": [
77 "name",
78 "resources"
79 ],
80 "additionalProperties": false
81 }
82 },
83 "dataGroups": {
84 "type": "array",
85 "description": "Policies for caching data requests, such as API requests and other data dependencies. Unlike asset resources, data requests are not versioned along with the app.",
86 "items": {
87 "type": "object",
88 "properties": {
89 "name": {
90 "type": "string",
91 "description": "It identifies this particular group of data between versions of the configuration."
92 },
93 "urls": {
94 "type": "array",
95 "description": "A list of URL patterns. URLs that match these patterns will be cached according to this data group's policy. (Negative glob patterns are not supported and '?' will be matched literally; i.e. it will not match any character other than '?'.)",
96 "items": {
97 "type": "string"
98 },
99 "uniqueItems": true
100 },
101 "version": {
102 "type": "integer",
103 "default": 1,
104 "description": "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. '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."
105 },
106 "cacheConfig": {
107 "type": "object",
108 "description": "This section defines the policy by which matching requests will be cached.",
109 "properties": {
110 "maxSize": {
111 "type": "integer",
112 "description": "The maximum number of entries, or responses, in the cache. Open-ended caches can grow in unbounded ways and eventually exceed storage quotas, calling for eviction."
113 },
114 "maxAge": {
115 "type": "string",
116 "description": "Indicates how long responses are allowed to remain in the cache before being considered invalid and evicted. 'maxAge' is a duration string, using the following unit suffixes: d= days, h= hours, m= minutes, s= seconds, u= milliseconds. For example, the string '3d12h' will cache content for up to three and a half days."
117 },
118 "timeout": {
119 "type": "string",
120 "description": "This duration string specifies the network timeout. The network timeout is how long the Angular service worker will wait for the network to respond before using a cached response, if configured to do so. 'timeout' is a duration string, using the following unit suffixes: d= days, h= hours, m= minutes, s= seconds, u= milliseconds. For example, the string '5s30u' will translate to five seconds and 30 milliseconds of network timeout."
121 },
122 "strategy": {
123 "enum": [
124 "freshness",
125 "performance"
126 ],
127 "default": "performance",
128 "description": "The Angular service worker can use either of two caching strategies for data resources. '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. '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."
129 },
130 "cacheOpaqueResponses": {
131 "type": "boolean",
132 "description": "Whether to cache opaque responses or not. The default value is 'false' for groups with the 'performance' strategy and 'true' for groups with the 'freshness' strategy. Opaque responses are special in that it is not possible for the service worker to distinguish successful responses from errors. Therefore, be careful with caching opaque responses, especially when combined with a strategy/configuration that could result in a response being retained in the cache for a long time."
133 }
134 },
135 "required": [
136 "maxSize",
137 "maxAge"
138 ],
139 "additionalProperties": false
140 },
141 "cacheQueryOptions" : {
142 "type": "object",
143 "description": "Provide options that are passed to Cache#match.",
144 "properties" : {
145 "ignoreSearch": {
146 "type": "boolean",
147 "description": "Whether to ignore the query string in the URL."
148 }
149 },
150 "additionalProperties": false
151 }
152 },
153 "required": [
154 "name",
155 "urls",
156 "cacheConfig"
157 ],
158 "additionalProperties": false
159 }
160 },
161 "navigationUrls": {
162 "type": "array",
163 "description": "This optional section enables you to specify a custom list of URLs or URL patterns that will be redirected to the 'index' file.",
164 "items": {
165 "type": "string"
166 },
167 "uniqueItems": true
168 },
169 "navigationRequestStrategy": {
170 "enum": [
171 "freshness",
172 "performance"
173 ],
174 "default": "performance",
175 "description": "The Angular service worker can use two request strategies for navigation requests. 'performance', the default, skips navigation requests. The other strategy, 'freshness', forces all navigation requests through the network."
176 }
177 },
178 "required": [
179 "index"
180 ],
181 "additionalProperties": false
182}