Sunday, May 19, 2024
 Popular · Latest · Hot · Upcoming
19
rated 0 times [  20] [ 1]  / answers: 1 / hits: 20157  / 10 Years ago, fri, february 21, 2014, 12:00:00

i like to include templates with the ng-include attribute. I like to know if the templates getting cached while using the the same url multiple times.



<div ng-include src='./Views/temp.html'></div> //get request temp.html
<div ng-include src='./Views/temp.html'></div> //load from cache

More From » angularjs

 Answers
38

Caching is typically used - but its not on the part of angular but instead on the part of the browser. You can see this by running Fiddler and seeing what happens when your page loads. If you get a 304 result code back from the server it means that the page hasn't changed - so it will be pulled from cache.



Force Reload



The only good way to consistently force a reload is to add query string as follows (you can replace i with any variable you would like and the numbers just need to be random - not previously used numbers):



<div ng-include src='./Views/temp.html?i=1000'></div> // get request temp.html
<div ng-include src='./Views/temp.html?i=1001'></div> // force the page to load!


Hope that helps!


[#72393] Thursday, February 20, 2014, 10 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
bryonk

Total Points: 161
Total Questions: 116
Total Answers: 107

Location: Albania
Member since Sun, Nov 22, 2020
4 Years ago
bryonk questions
;