-
-
Save zxjon22/fd823c0bcc966d70095dea845056e87f to your computer and use it in GitHub Desktop.
Elegant cache-busting for AngularJS HTML assets
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
anglar.module('myApp',['ui']).config(["$provide", function($provide) { | |
return $provide.decorator("$http", ["$delegate", function($delegate) { | |
var get = $delegate.get; | |
$delegate.get = function(url, config) { | |
// Check is to avoid breaking AngularUI ui-bootstrap-tpls.js: "template/accordion/accordion-group.html" | |
if (!~url.indexOf('template/')) { | |
// Append ?v=[cacheBustVersion] to url | |
url += (url.indexOf("?") === -1 ? "?" : "&"); | |
url += "v=" + cacheBustVersion; | |
} | |
return get(url, config); | |
}; | |
return $delegate; | |
}]); | |
}]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment