In my previous post (https://www.roelvanlisdonk.nl/?p=4550) I explained how to:
– create a new ASP .NET MVC 5 .NET 4.6 project in Visual Studio 2015
– add static caching, add url rewrites
– add fingerprinting to the “folder part” of each URL, to bust the client cache, when a new build is deployed to the website
Now if you don’t want to use the URL Rewrite approach, but you still want to fingerprint the “folder url part” of the bundels created with the System.Web.Optimization (instead of using the standard query parameter cache busting technique), you can use the following class:
Use this class, when the bundles are created and when they are used inside the *.cshtml:
Then inside a *.cshtml page:
In this way, only the “name” of the bundle is fingerprinted and bundeling will only take place in “release” build.
The System.Web.Optimization will take care of the “cache busting”, no need for “URL rewriting”.
The code uses the following extension method: