PTrampert.Webpack.CacheBuster

Nuget package and webpack plugin to help with cache busting webpacked resources in your Razor views.


Keywords
cachebusting, cache, busting, webpack, chunkhash, chunk, hash
License
MIT
Install
Install-Package PTrampert.Webpack.CacheBuster -Version 3.0.0

Documentation

PTrampert.Webpack.CacheBuster

Cache busts static files referenced in your cshtml files.

Usage

  1. In Startup.ConfigureServices, add the following:
services.AddCacheBusting();
  1. In either your _ViewImports.cshtml or your specific view, add the following:
@using PTrampert.Webpack.CacheBuster
@addTagHelper "*, PTrampert.Webpack.CacheBuster"
  1. You can now use the cache-bust attribute in your script and link tags.
<!-- This assumes you have a file in your webroot called `index.js` -->
<script cache-bust="~/index.js"></script>
<!-- This tag would be rendered as <script src="/web/root/path/index.js?v=[chunkhash]"></script> -->