Cache busts static files referenced in your cshtml files.
- In
Startup.ConfigureServices
, add the following:
services.AddCacheBusting();
- In either your
_ViewImports.cshtml
or your specific view, add the following:
@using PTrampert.Webpack.CacheBuster
@addTagHelper "*, PTrampert.Webpack.CacheBuster"
- 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> -->