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.
Asked
Active
Viewed 2,664 times
0
-
What makes you think those responses were cached? – Nov 30 '16 at 06:37
-
I am using a chrome extension ( Clear All Cache ) to one click remove caceh. after clearing cache and refreshing page. its working fine. – AWE Nov 30 '16 at 06:42
2 Answers
0
try this
app.run(function($rootScope, $templateCache) {
$rootScope.$on('$routeChangeStart', function(event, next, current) {
if (typeof(current) !== 'undefined'){
$templateCache.remove(current.templateUrl);
}
});
});
Sajeetharan
- 203,447
- 57
- 330
- 376
-
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! – staminna Jul 22 '21 at 15:53
0
If you are talking about development environment, you can disable browser cache when console is open.
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.
Icycool
- 6,724
- 1
- 21
- 31