[Blazor-Wasm-PWA] Service Worker downloads redundant files making the initial resource download size double
See original GitHub issueDescription:
It might be a non-issue but being a noob in blazor I tried to search for answers everywhere on the internet without any luck of finding answer/issue mentioned anywhere, so I decided to post it here
I built an blazor wasm pwa app and hosted it on Github pages: Here is the url: https://paragraut.github.io/ComicsAppWasm/
What I saw in initial load of the website on let’s say incognito mode I see redundant downloads of same files, one was loaded by default and one was loaded by service worker as shown below
Making download size double than original
My question is: Is it normal ? does service worker always worked this way ?
To Reproduce
To reproduce it go to incognito mode and open network tab on developer options, then navigate to https://paragraut.github.io/ComicsAppWasm/ and observer same resource files being downloaded twice.
Not just on GitHub Pages but when I also tried to host it on IIS I faced same issue.
Technical details
- ASP.NET Core version : 3.1.300
- Output of
dotnet --info
.NET Core SDK (reflecting any global.json): Version: 3.1.300 Commit: b2475c1295
Runtime Environment: OS Name: Windows OS Version: 10.0.17134 OS Platform: Windows RID: win10-x64 Base Path: C:\Program Files\dotnet\sdk\3.1.300\
Host (useful for support): Version: 3.1.4 Commit: 0c2e69caa6
.NET Core SDKs installed: 3.1.300 [C:\Program Files\dotnet\sdk]
.NET Core runtimes installed: Microsoft.AspNetCore.All 2.1.18 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.App 2.1.18 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 3.1.4 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.NETCore.App 2.1.18 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 3.1.4 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.WindowsDesktop.App 3.1.4 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
To install additional .NET Core runtimes or SDKs: https://aka.ms/dotnet-download
IDE
- Visual Studio 16.6.1
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (2 by maintainers)
@ParagRaut It is not part of the standard framework, it is likely a transitive dependency on a package you might have installed and that’s why its there. Blazor uses System.Text.Json by default.
@ParagRaut thanks for contacting us.
One download corresponds to the app loading and another one corresponds to the service worker caching the downloaded assets while getting installed.
AFAIK there is no way to prevent that, since the app needs to be independent of the service worker being present or not. Once the service worker is installed or after the first visit, you shouldn’t see any duplicate downloads