I'm a technologist, speaker, and Pluralsight author and I specialize in building full-stack solutions with a focus on modern web technology and cloud native architecture.
I just published a new Nuget package, AspNet.Mvc.AssetVersioning. This package extends the MVC5
@Url Razor helper with a new
which appends a Base64-encoded SHA256 hash to the end of the URL for cache-busting.
In ASP.NET Core, you can version URLs using the
asp-append-version tag helper:
Which will output:
Since I have not yet migrated to ASP.NET Core for Keep Track of My Games, I needed the same functionality in order to remove some old libraries that are not available in .NET Core. Now you can achieve the same thing using my package:
This will output the following:
The helper will automatically cache hashes for files for the lifetime of the
HttpContext. So, basically, for the lifetime of the application pool. Restart the site/app pool to refresh the cache, which should happen on any new deployments.
You can simplify the
@using statement usage by adding the namespace to the
/configuration/system.web.webPages.razor/pages/namespaces section in the
Views/web.config file, as outlined in the GitHub repo README.
Hope this helps someone else facing the same issue!
No spam and I usually send a newsletter once a quarter with content you won't see on the blog.