MR.ABC MR.ABC - 1 year ago 205
AngularJS Question

AngularJS ng-include caching

i like to include templates with the

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

Answer Source

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!

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download