Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add cache-buster to non-optimized bundle?

I'm using Bundling in MVC and have the following:

@Scripts.Render("~/bundles/scripts.js");

When BundleTable.EnableOptimizations = true this renders as:

<script src="/bundles/scripts.js?v=RF3ov56782q9Tc_sMO4vwTzfffl16c6bRblXuygjwWE1"></script>

When BundleTable.EnableOptimizations = false this renders as:

<script src="/js/header.js"></script>
<script src="/js/content.js"></script>
<script src="/js/footer.js"></script>

Is it possible to intercept the non-optimized version to include my own custom cache buster?

For example:

<script src="/js/header.js?v=12345"></script>
<script src="/js/content.js?v=12345"></script>
<script src="/js/footer.js?v=12345"></script>
like image 708
Curtis Avatar asked Sep 17 '14 15:09

Curtis


1 Answers

Why do you need to? In development, where BundleTable.EnableOptimizations = false nothing is cached anyways, and in production you should have BundleTable.EnableOptimizations = true also negating the need for something like this.

The short answer, is no, there's nothing built in to allow you to do what you ask, primarily because of the reasons I've already stated: there's simply no need for such a feature.

like image 151
Chris Pratt Avatar answered Oct 15 '22 19:10

Chris Pratt