Skip to content

Commit db376e6

Browse files
authored
Blazor PWA node and push notifications article (#35688)
1 parent ca1cc62 commit db376e6

20 files changed

+385
-19
lines changed

.openpublishing.redirection.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1522,6 +1522,11 @@
15221522
"source_path": "aspnetcore/migration/identity.md",
15231523
"redirect_url": "/aspnet/core/migration/fx-to-core/examples/identity",
15241524
"redirect_document_id": false
1525+
},
1526+
{
1527+
"source_path": "aspnetcore/blazor/progressive-web-app.md",
1528+
"redirect_url": "/aspnet/core/blazor/progressive-web-app/",
1529+
"redirect_document_id": false
15251530
}
15261531
]
15271532
}

aspnetcore/blazor/fundamentals/configuration.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -300,12 +300,12 @@ var hostname = builder.Configuration["HostName"];
300300

301301
## Cached configuration
302302

303-
Configuration files are cached for offline use. With [Progressive Web Applications (PWAs)](xref:blazor/progressive-web-app), you can only update configuration files when creating a new deployment. Editing configuration files between deployments has no effect because:
303+
Configuration files are cached for offline use. With [Progressive Web Applications (PWAs)](xref:blazor/progressive-web-app/index), you can only update configuration files when creating a new deployment. Editing configuration files between deployments has no effect because:
304304

305305
* Users have cached versions of the files that they continue to use.
306306
* The PWA's `service-worker.js` and `service-worker-assets.js` files must be rebuilt on compilation, which signal to the app on the user's next online visit that the app has been redeployed.
307307

308-
For more information on how background updates are handled by PWAs, see <xref:blazor/progressive-web-app#background-updates>.
308+
For more information on how background updates are handled by PWAs, see <xref:blazor/progressive-web-app/index#background-updates>.
309309

310310
## Options configuration
311311

aspnetcore/blazor/host-and-deploy/webassembly/bundle-caching-and-integrity-check-failures.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ To disable integrity checks, add the following to a property group in the Blazor
154154
`BlazorCacheBootResources` also disables Blazor's default behavior of caching the `.dll`, `.wasm`, and other files based on their SHA-256 hashes because the property indicates that the SHA-256 hashes can't be relied upon for correctness. Even with this setting, the browser's normal HTTP cache may still cache those files, but whether or not this happens depends on your web server configuration and the `cache-control` headers that it serves.
155155

156156
> [!NOTE]
157-
> The `BlazorCacheBootResources` property doesn't disable integrity checks for [Progressive Web Applications (PWAs)](xref:blazor/progressive-web-app). For guidance pertaining to PWAs, see the [Disable integrity checking for PWAs](#disable-integrity-checking-for-pwas) section.
157+
> The `BlazorCacheBootResources` property doesn't disable integrity checks for [Progressive Web Applications (PWAs)](xref:blazor/progressive-web-app/index). For guidance pertaining to PWAs, see the [Disable integrity checking for PWAs](#disable-integrity-checking-for-pwas) section.
158158
159159
We can't provide an exhaustive list of scenarios where disabling integrity checking is required. Servers can answer a request in arbitrary ways outside of the scope of the Blazor framework. The framework provides the `BlazorCacheBootResources` setting to make the app runnable at the cost of *losing a guarantee of integrity that the app can provide*. Again, we don't recommend disabling integrity checking, especially for production deployments. Developers should seek to solve the underlying integrity problem that's causing integrity checking to fail.
160160

aspnetcore/blazor/host-and-deploy/webassembly/index.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,7 @@ Rename file extensions in the `blazor.boot.json` file:
483483
((Get-Content {PATH}\blazor.boot.json -Raw) -replace '.dll"','.bin"') | Set-Content {PATH}\blazor.boot.json
484484
```
485485

486-
If service worker assets are also in use because the app is a [Progressive Web App (PWA)](xref:blazor/progressive-web-app):
486+
If service worker assets are also in use because the app is a [Progressive Web App (PWA)](xref:blazor/progressive-web-app/index):
487487

488488
```powershell
489489
((Get-Content {PATH}\service-worker-assets.js -Raw) -replace '.dll"','.bin"') | Set-Content {PATH}\service-worker-assets.js
@@ -507,7 +507,7 @@ Rename file extensions in the `blazor.boot.json` file:
507507
sed -i 's/\.dll"/.bin"/g' {PATH}/blazor.boot.json
508508
```
509509

510-
If service worker assets are also in use because the app is a [Progressive Web App (PWA)](xref:blazor/progressive-web-app):
510+
If service worker assets are also in use because the app is a [Progressive Web App (PWA)](xref:blazor/progressive-web-app/index):
511511

512512
```console
513513
sed -i 's/\.dll"/.bin"/g' {PATH}/service-worker-assets.js
@@ -522,12 +522,12 @@ To address the compressed `blazor.boot.json` file, adopt either of the following
522522
* Recompress the updated `blazor.boot.json` file, producing new `blazor.boot.json.gz` and `blazor.boot.json.br` files. (*Recommended*)
523523
* Remove the compressed `blazor.boot.json.gz` and `blazor.boot.json.br` files. (*Compression is disabled with this approach.*)
524524

525-
For a [Progressive Web App (PWA)](xref:blazor/progressive-web-app)'s compressed `service-worker-assets.js` file, adopt either of the following approaches:
525+
For a [Progressive Web App (PWA)](xref:blazor/progressive-web-app/index)'s compressed `service-worker-assets.js` file, adopt either of the following approaches:
526526

527527
* Recompress the updated `service-worker-assets.js` file, producing new `service-worker-assets.js.br` and `service-worker-assets.js.gz` files. (*Recommended*)
528528
* Remove the compressed `service-worker-assets.js.gz` and `service-worker-assets.js.br` files. (*Compression is disabled with this approach.*)
529529

530-
To automate the extension change on Windows in .NET 6/7, the following approach uses a PowerShell script placed at the root of the project. The following script, which disables compression, is the basis for further modification if you wish to recompress the `blazor.boot.json` file and `service-worker-assets.js` file if the app is a [Progressive Web App (PWA)](xref:blazor/progressive-web-app). The path to the [`publish` folder](xref:blazor/host-and-deploy/index#default-publish-locations) is passed to the script when it's executed.
530+
To automate the extension change on Windows in .NET 6/7, the following approach uses a PowerShell script placed at the root of the project. The following script, which disables compression, is the basis for further modification if you wish to recompress the `blazor.boot.json` file and `service-worker-assets.js` file if the app is a [Progressive Web App (PWA)](xref:blazor/progressive-web-app/index). The path to the [`publish` folder](xref:blazor/host-and-deploy/index#default-publish-locations) is passed to the script when it's executed.
531531

532532
`ChangeDLLExtensions.ps1:`:
533533

@@ -539,7 +539,7 @@ Remove-Item $filepath\wwwroot\_framework\blazor.boot.json.gz
539539
Remove-Item $filepath\wwwroot\_framework\blazor.boot.json.br
540540
```
541541

542-
If service worker assets are also in use because the app is a [Progressive Web App (PWA)](xref:blazor/progressive-web-app), add the following commands:
542+
If service worker assets are also in use because the app is a [Progressive Web App (PWA)](xref:blazor/progressive-web-app/index), add the following commands:
543543

544544
```powershell
545545
((Get-Content $filepath\wwwroot\service-worker-assets.js -Raw) -replace '.dll"','.bin"') | Set-Content $filepath\wwwroot\service-worker-assets.js

aspnetcore/blazor/hosting-models.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ When a standalone Blazor WebAssembly app uses a backend ASP.NET Core app to serv
101101

102102
:::moniker range=">= aspnetcore-6.0"
103103

104-
A Blazor WebAssembly app built as a [Progressive Web App (PWA)](xref:blazor/progressive-web-app) uses modern browser APIs to enable many of the capabilities of a native client app, such as working offline, running in its own app window, launching from the host's operating system, receiving push notifications, and automatically updating in the background.
104+
A Blazor WebAssembly app built as a [Progressive Web App (PWA)](xref:blazor/progressive-web-app/index) uses modern browser APIs to enable many of the capabilities of a native client app, such as working offline, running in its own app window, launching from the host's operating system, receiving push notifications, and automatically updating in the background.
105105

106106
:::moniker-end
107107

aspnetcore/blazor/progressive-web-app.md renamed to aspnetcore/blazor/progressive-web-app/index.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ monikerRange: '>= aspnetcore-3.1'
66
ms.author: wpickett
77
ms.custom: mvc
88
ms.date: 11/12/2024
9-
uid: blazor/progressive-web-app
9+
uid: blazor/progressive-web-app/index
1010
---
1111
# ASP.NET Core Blazor Progressive Web Application (PWA)
1212

@@ -159,13 +159,13 @@ In the app's `wwwroot/index.html` file:
159159

160160
When visiting an app created using the PWA template, users have the option of installing the app into their OS's start menu, dock, or home screen. The way this option is presented depends on the user's browser. When using desktop Chromium-based browsers, such as Edge or Chrome, an **Add** button appears within the URL bar. After the user selects the **Add** button, they receive a confirmation dialog:
161161

162-
![The confirmation dialog in Google Chrome presents an Install button to the user for the 'MyBlazorPwa' app.](~/blazor/progressive-web-app/_static/image2.png)
162+
![The confirmation dialog in Google Chrome presents an Install button to the user for the 'MyBlazorPwa' app.](~/blazor/progressive-web-app/index/_static/image2.png)
163163

164164
On iOS, visitors can install the PWA using Safari's **Share** button and its **Add to Homescreen** option. On Chrome for Android, users should select the **Menu** button in the upper-right corner, followed by **Add to Home screen**.
165165

166166
Once installed, the app appears in its own window without an address bar:
167167

168-
![The 'MyBlazorPwa' app runs in Google Chrome without an address bar.](~/blazor/progressive-web-app/_static/image3.png)
168+
![The 'MyBlazorPwa' app runs in Google Chrome without an address bar.](~/blazor/progressive-web-app/index/_static/image3.png)
169169

170170
To customize the window's title, color scheme, icon, or other details, see the `manifest.json` file in the project's `wwwroot` directory. The schema of this file is defined by web standards. For more information, see [MDN web docs: Web App Manifest](https://developer.mozilla.org/docs/Web/Manifest).
171171

@@ -185,18 +185,18 @@ To see how offline support works:
185185
1. Deploy the app to a server that supports HTTPS, and access the app in a browser at its secure HTTPS address.
186186
1. Open the browser's dev tools and verify that a *Service Worker* is registered for the host on the **Application** tab:
187187

188-
![Google Chrome developer tools 'Application' tab shows a Service Worker activated and running.](~/blazor/progressive-web-app/_static/image4.png)
188+
![Google Chrome developer tools 'Application' tab shows a Service Worker activated and running.](~/blazor/progressive-web-app/index/_static/image4.png)
189189

190190
1. Reload the page and examine the **Network** tab. **Service Worker** or **memory cache** are listed as the sources for all of the page's assets:
191191

192-
![Google Chrome developer tools 'Network' tab showing sources for all of the page's assets.](~/blazor/progressive-web-app/_static/image5.png)
192+
![Google Chrome developer tools 'Network' tab showing sources for all of the page's assets.](~/blazor/progressive-web-app/index/_static/image5.png)
193193

194194
1. To verify that the browser isn't dependent on network access to load the app, either:
195195

196196
* Shut down the web server and see how the app continues to function normally, which includes page reloads. Likewise, the app continues to function normally when there's a slow network connection.
197197
* Instruct the browser to simulate offline mode in the **Network** tab:
198198

199-
![Google Chrome developer tools 'Network' tab with the browser mode dropdown list changed from 'Online' to 'Offline'.](~/blazor/progressive-web-app/_static/image6.png)
199+
![Google Chrome developer tools 'Network' tab with the browser mode dropdown list changed from 'Online' to 'Offline'.](~/blazor/progressive-web-app/index/_static/image6.png)
200200

201201
Offline support using a service worker is a web standard, not specific to Blazor. For more information on service workers, see [MDN web docs: Service Worker API](https://developer.mozilla.org/docs/Web/API/Service_Worker_API). To learn more about common usage patterns for service workers, see [Google Web: The Service Worker Lifecycle](https://web.dev/service-worker-lifecycle/).
202202

@@ -358,7 +358,7 @@ What surprises many developers is that, even when this update completes, it does
358358

359359
This commonly troubles developers who are trying to test updates to their service worker or offline cached resources. If you check in the browser's developer tools, you may see something like the following:
360360

361-
![Google Chrome 'Application' tab shows that the Service Worker of the app is 'waiting to activate'.](~/blazor/progressive-web-app/_static/image7.png)
361+
![Google Chrome 'Application' tab shows that the Service Worker of the app is 'waiting to activate'.](~/blazor/progressive-web-app/index/_static/image7.png)
362362

363363
For as long as the list of "clients," which are tabs or windows displaying your app, is nonempty, the worker continues waiting. The reason service workers do this is to guarantee consistency. Consistency means that all resources are fetched from the same atomic cache.
364364

0 commit comments

Comments
 (0)