Surface URL exclusion for PWA cached content (#21257)

pull/21260/head
Luke Latham 2021-01-20 08:27:52 -06:00 committed by GitHub
parent 13a615e394
commit 51e639b47d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 1 deletions

View File

@ -255,11 +255,21 @@ Change the code to the following:
```javascript
const shouldServeIndexHtml = event.request.mode === 'navigate'
&& !event.request.url.includes('/Identity/');
&& !event.request.url.includes('/Identity/');
```
If you don't do this, then regardless of network connectivity, the service worker intercepts requests for such URLs and resolves them using `/index.html`.
Add additional endpoints for external authentication providers to the check. In the following example, `/signin-google` for Google authentication is added to the check:
```javascript
const shouldServeIndexHtml = event.request.mode === 'navigate'
&& !event.request.url.includes('/Identity/')
&& !event.request.url.includes('/signin-google');
```
No action is required for the Development environment, where content is always fetched from the network.
### Control asset caching
If your project defines the `ServiceWorkerAssetsManifest` MSBuild property, Blazor's build tooling generates a service worker assets manifest with the specified name. The default PWA template produces a project file containing the following property: