javascript - AngularJS: what is $templateCache? -
while profiling large angularjs app, started tracking $templatecache.
https://docs.angularjs.org/api/ng/service/$templatecache
what object? store partials stored on disk or final rendered html route?
i've added code controller make sure it's not persisting anything:
$scope.$on('$destroy', function cleanup() { $templatecache.removeall(); });
edit: reason looking single (not every) controller loading large partial several loops inside of it, depending on user input 100 input fields large <select>
statements , many custom directives. client requesting way , want make sure of getting disposed during routing.
to clarify question: $templatecache storing partials appear on disk, no routing or rendering information being stored?
by default, while loading templates, angular looks inside $templatecache , fetches templates on xhr when cannot find them locally in $templatecache. when xhr request slow or our template large enough, can negatively impact end users’ experience . instead of fetching templates xhr, can fake template cache loading wrapping javascript file , shipp javascript file along rest of application.
sample :
angular.module('myapp') .run(['$templatecache', function($templatecache) { $templatecache.put('xyz.html', ...); }]);
so, unless sure remove cached templates form $templatecache, don't that.
Comments
Post a Comment