Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AngularJS ng-include caching

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
like image 855
MR.ABC Avatar asked Feb 21 '14 13:02

MR.ABC


1 Answers

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!

like image 148
drew_w Avatar answered Nov 09 '22 08:11

drew_w