1

I am here to discus my problem with my AngularJS project. currently everything is working. Getting response from APIs and setting data from API. but sometimes it get 400 error due to cache. after removing cache again works fine. So I want to build a code for when I refresh page cache should be removed. I tried $templateCache but not working anymore.

enter image description here

2
  • What makes you think those responses were cached? Commented Nov 30, 2016 at 6:37
  • I am using a chrome extension ( Clear All Cache ) to one click remove caceh. after clearing cache and refreshing page. its working fine. Commented Nov 30, 2016 at 6:42

2 Answers 2

1

try this

  app.run(function($rootScope, $templateCache) {
        $rootScope.$on('$routeChangeStart', function(event, next, current) {
            if (typeof(current) !== 'undefined'){
                $templateCache.remove(current.templateUrl);
            }
        });
    });
Sign up to request clarification or add additional context in comments.

1 Comment

I know it is old thread but can you ellaborate? I went ahead and tried in my ng-controller.js file but either it worked and I couldn't tell it was working, or it didn't. Where should I be looking at? Thanks in advance!
0

If you are talking about development environment, you can disable browser cache when console is open.

enter image description here

I'm pretty sure Firefox and IE have that option too.

If you are talking about production environment, you'll need to look into javascript cache breaker.

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.