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
feat(service-worker): allow specifying maxAge for entire application (#49601)
This commit adds an `applicationMaxAge` to the service worker configuration. When set, it will only assign a cached version to clients within the `maxAge`. Afterwards, it will ignored any expired application versions and fetch exclusively from the network. The default is `undefined`, for which the behaviour is the same as it currently is.
PR Close#49601
Copy file name to clipboardExpand all lines: adev/src/content/ecosystem/service-workers/config.md
+5-1
Original file line number
Diff line number
Diff line change
@@ -347,7 +347,7 @@ A request is considered to be a navigation request if:
347
347
* The URL must not contain a file extension (that is, a `.`) in the last path segment
348
348
* The URL must not contain `__`
349
349
350
-
HELPFUL: To configure whether navigation requests are sent through to the network or not, see the [navigationRequestStrategy](#navigationrequeststrategy) section.
350
+
HELPFUL: To configure whether navigation requests are sent through to the network or not, see the [navigationRequestStrategy](#navigationrequeststrategy) section and [applicationMaxAge](#application-max-age) sections.
351
351
352
352
#### Matching navigation request URLs
353
353
@@ -391,3 +391,7 @@ This optional property enables you to configure how the service worker handles n
391
391
|`'freshness'`| Passes the requests through to the network and falls back to the `performance` behavior when offline. This value is useful when the server redirects the navigation requests elsewhere using a `3xx` HTTP redirect status code. Reasons for using this value include: <ul> <li> Redirecting to an authentication website when authentication is not handled by the application </li> <li> Redirecting specific URLs to avoid breaking existing links/bookmarks after a website redesign </li> <li> Redirecting to a different website, such as a server-status page, while a page is temporarily down </li> </ul> |
392
392
393
393
IMPORTANT: The `freshness` strategy usually results in more requests sent to the server, which can increase response latency. It is recommended that you use the default performance strategy whenever possible.
394
+
395
+
### `applicationMaxAge`
396
+
397
+
This optional property enables you to configure how long the service worker will cache any requests. Within the `maxAge`, files will be served from cache. Beyond it, all requests will only be served from the network, including asset and data requests.
Copy file name to clipboardExpand all lines: packages/service-worker/config/schema.json
+4
Original file line number
Diff line number
Diff line change
@@ -177,6 +177,10 @@
177
177
],
178
178
"default": "performance",
179
179
"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."
180
+
},
181
+
"applicationMaxAge": {
182
+
"type": "string",
183
+
"description": "Indicates how long the entire application is allowed to remain in the cache before being considered invalid and bypassed. '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."
0 commit comments