I am fiddling with the default VS2019 (16.6.5) Blazor WebAssembly project. However when I look at Chrome (or Firefox or Edge) > Developer Tools [F12] > network, with Disable Cache enabled, I don't see much being loaded?
In the Dev Tool > Sources I can see that dotnet.wasm has been loaded somehow.
And by reading some articles like this one I see screenshots that show DLL and wasm being loaded.
Why don't I see that?
Edit: Ok I succeed to see DLLs loaded like I want only when starting debugging the Blazor WebAssembly project from VS2019. When I start the project without debugging, I still get the same lightweight load as in the first screenshot. Why?
Open Visual Studio and select Create a new project. Select the Blazor WebAssembly App project type, enter a name for your project, and then click Next. Select the ASP.NET Core hosted checkbox and the desired framework, and then click Create.
The Blazor Server hosting model offers several benefits: Download size is significantly smaller than a Blazor WebAssembly app, and the app loads much faster. The app takes full advantage of server capabilities, including the use of . NET Core APIs.
Blazor can run your client-side C# code directly in the browser, using WebAssembly. Because it's real .NET running on WebAssembly, you can re-use code and libraries from server-side parts of your application.
Blazor WASM changed the loading behaviour just before RTM version 3.2 was released (May 2020) so the examples prior to this demonstrate the old behaviour.
When a Blazor WASM application loads, it creates a manifest and checksum for each DLL, this is loaded in blazor.boot.json
The Blazor code will check for these files (and the checksum) in the Browser's Cache storage. Note this is not the same cache the browser uses for normal content, e.g. HTML, CSS etc.
If they're not present (the first run) they are loaded. You can see the files that were loaded here:
These files are loaded on the first run. In future page views, if the filename and checksum matches, it won't be reloaded even if you select the browser's "Empty Cache and Hard Reload"
Why? This makes sense because files like mscorlib.dll
won't have changed due to an app recompiling. This isn't JavaScript, it's a binary. The SHA256 checksum verifies it's the same file.
However your Blazor app DLLs will change if you edit and recompile. If they do they get reloaded:
If you want to force a full reload, you can navigate to the Browsers Cache (under Application in Chrome developer tools), and select Delete for your site.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With