This package deals with making sure lib.module.js files are clear when a new deployment is made or when you update them Aswell as replacing script links in your index.html
Note: This is the poor mans version of StaticAssets, but this works for standalone WASM...
For more information on javascript initializers: (more info here)
- Add the nuget package in your Client (wasm) AND your Server (if using Blazor wasm hosted) projects.
dotnet add package BlazorCacheBuster
- Update the script references in your index.html and append the query string for cache busting (q=cache)
<script src="_content/MudBlazor/MudBlazor.min.js?q=cache"></script>
<script src="test.js?q=cache"></script>
- Publish your app in Release mode and test it!
dotnet publish Client\Sample.csproj -c Release
Nuget package page can be found here.
The following options allow you to customize the tasks executed by this package.
If you want to use a different query string for busting the cache (for FALLBACK non-relative), for example a specific version, add the following property in the published project's .csproj file (Server project if using Blazor hosted).
<!-- By default it will be a new guid for every publish. -->
<BlazorCacheId>1</BlazorCacheId>
If you want a more automated way of doing this. By setting the following property this package will REPLACE the hash of the file as a query string
<!-- By default this is enabled, alteast for now. -->
<BlazorCacheBustIndexHtml>false</BlazorCacheBustIndexHtml>
You can disable the cache busting add the following property in the published project's .csproj file (Server project if using Blazor hosted).
<BlazorDisableCacheBusting>true</BlazorDisableCacheBusting>