[英]AngularJS ng-include caching
我想包含带有ng-include
属性的模板。 我想知道模板是否在多次使用相同的URL时被缓存。
<div ng-include src="'./Views/temp.html'"></div> //get request temp.html
<div ng-include src="'./Views/temp.html'"></div> //load from cache
高速缓存通常用于-但它不是对角的一部分,而是在浏览器上的一部分。 您可以通过运行Fiddler并查看页面加载时会发生什么来看到这一点。 如果从服务器返回304结果代码,则表示页面未更改 - 因此将从缓存中提取。
强制重新加载
一致强制重新加载的唯一好方法是添加查询字符串,如下所示(您可以将“i”替换为您想要的任何变量,数字只需要是随机的 - 不是以前使用过的数字):
<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!
希望有所帮助!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.