Tip 1: Add a Query to the URL
I understand, it can be tedious having to manually add an alphanumeric string to the end of the URL to force the browser to load the latest version of the files. And frankly, most of the time, you end up forgetting to do it. Conclusion: forget it ❌
Tip 3: Via a variable in appsettings.json
This is a really elegant way of handling it. By using a variable like “BUILD_NUMBER” in your appsettings.json file and retrieving it via IConfiguration in your application, you can dynamically incorporate this value into the routing file such as Routes.razor (or App.Razor for versions prior to .NET 8). This allows you to control resource URLs from a centralized source, simplifying cache-busting management for your entire application.
The advantage of the latter solution is that you can modify this variable during deployment via your CI/CD pipeline.
Tip 4 : Use AssemblyVersion with reflection
In use, it looks like this:
So in the .csproj file, even though we’re already using , we’re going to add here:
It’s an easy solution that I like