Himanshu Pandey
Himanshu Pandey

Reputation: 1270

Remove one day old template from cache Angular 1?

I am using following rule to remove template cache on angular js application

myApp.run(function ($rootScope, $templateCache) {
    $rootScope.$on('$viewContentLoaded', function() {
      $templateCache.removeAll();
   });
});

Now I have to remove only one day old template cache, not all. How I achieve this?

My angular version is 1.2.23.

Upvotes: 1

Views: 99

Answers (1)

leaf
leaf

Reputation: 1764

You can use $templateCache.remove(name) if it's possible to record all one day old templates' names.

$templateCache has no API to get template name, so maybe you need to store the template names with timestamp in another variable when put them in the cache. Now you can compare their timestamp with current time to decide to delete or not.

Upvotes: 1

Related Questions