0

I would like to know if exists any way to add a suffix like

'app/account/script.js?v=1.0',
'app/account/style.css?v=1.0',

to all requests in AngularJS, including to css and js files.

Using interceptors we can do something like this Angular template versioning

But unforntunelly that isn't a solution for me.

Thanks

1
  • Exactly, I want to invalidate browser cache using AngularJS Commented Sep 24, 2018 at 20:23

1 Answer 1

1

I solved with this

First in your app.js

app.value('version', '1.0.0');

then we add a new directive

app.directive('disableCache', function(version) {
    return {
        restrict: 'A',
        replace: false,
        link: function(scope, elem, attr) {
            attr.$set("src", attr.src +  "#v=" + version);
        }
    };
});

and we update our html

<script src="scripts/js/filters.js" disable-cache></script>

and will be

<script src="scripts/js/filters.js#v=1.0.0" disable-cache=""></script>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.