[英]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.