Reputation: 447
When I made changes in any template (html) in my code and refresh from browser then the changes does not occur in application.
I want to bypass template cache when I made changes in any template i.e I want when I make any changes in template and refresh from browser then the code should be updated code not from $templateCache
.
And how could I know that there is any changes in template programmatically?
I have tried this code too from Stackoverflow reference.
app.run(function($rootScope, $templateCache) {
$rootScope.$on('$viewContentLoaded', function($event) {
console.log($event);
alert("abc");
//$templateCache.removeAll();
$templateCache("templates").removeAll();
});
});
Upvotes: 0
Views: 833
Reputation: 31339
It's possible that the browser does some caching regardless of your logic.
Try sending the header: Cache-Control: no-cache
(section 14.9) if you never want a request cached.
no-cache:
If the no-cache directive does not specify a field-name, then a cache MUST NOT use the response to satisfy a subsequent request without successful revalidation with the origin server. This allows an origin server to prevent caching even by caches that have been configured to return stale responses to client requests.
For development you can also disable the cache in the browser, or use ctrl+f5
/ctrl+shift+R
or the key combination for your browser/os which will forcefully reload the page bypassing the cache.
Upvotes: 0
Reputation: 140
I assume this is due to you actively working on the webpage and want to see your changes immediately, and not something you actually need for production? If so, then you could just turn off the cache in your browser. In chrome you do this by going to developer tools -> Settings -> General and tick 'Disable cache (while DevTools is open)
Upvotes: 1