2017-07-05 93 views
1

我已經試過幾件事情要明確瀏覽器的緩存,同時pages.like cache: falseindex.html?x=1target="_self"disableCache: true, in $routeProvider as well之間的路由。但任何這對me.finaly $window.location.reload(); worked.but沒工作我不想在每次路由時重新加載頁面。在AngulerJs中,有沒有完美的路由緩存解決方案?如何清除路線之間的瀏覽器緩存AngularJS

場景

在我header.htmlng-if="currentPath ==='/store'"。它的檢查電流路徑和header.html

了header.html

<div class="container" ng-if="currentPath ==='/store'"> 
    <div class="col-xs-8 buttons" > 
     <a class="brand" href="#" target="_self"><img src="img/logo.png" /></a> 
     <a class="btns" href="#Store" target="_self">Store</a> 
    </div> 

<ul class="col-xs-4 icons"> 
     <li ><a href="#/profile" class="display_name"><i class="fa"></i>{{user.email}}</a></li> 
     <li><a href="#/cart"> <span ng-show="cart_size > 0" class="count">{{cart_size}}</span></a></li> 
</ul> 
<--some styles for store.......--> 
</div> 
<div class="container" ng-if="currentPath !=='/store'"> 
    <div class="col-xs-8 buttons" > 
     <a class="brand" href="#" target="_self"><img src="img/logo.png" /></a> 
     <a class="btns" href="#Store" target="_self">Store</a> 
    </div> 

    </div> 

本期顯示關於向store一些風格

當我進入store頁面我必須刷新瀏覽器才能在標題中顯示商店樣式。 之後,進入另一個頁面,商店風格仍然顯示在header.then我不得不再次刷新。 如何解決這個問題?

+0

您可以將版本設置爲您的js文件。它將幫助您正確加載模板。 –

+0

你可以嘗試'$ templateCache.removeAll()'來移除模板緩存 –

回答

0

您可以嘗試

angular.element('html[manifest=saveappoffline.appcache]').attr('content', ''); 

要禁用緩存。

清單屬性指定文檔的緩存清單的位置。

作爲每w3schools.com

HTML5引入應用程序緩存,這意味着,在Web應用程序 被高速緩存,並沒有連接到互聯網訪問。

應用程序緩存提供了一個應用三大優勢:

  1. 離線瀏覽 - 用戶可以使用時,他們離線 速度的應用 - 緩存資源加載速度更快

  2. 降低服務器負載 - 瀏覽器將只從服務器下載更新/更改的資源

清單屬性shou ld將包含在您要緩存的網頁 應用程序的每個頁面上。

清單文件是一個簡單的文本文件,其中列出了瀏覽器爲脫機訪問而緩存的資源。

要了解有關如何創建清單文件的更多信息,請閱讀我們的 HTML5應用程序緩存章節。

您可以嘗試的另一個解決方案是在您的角度應用程序標題中添加以下代碼段,以便您的頁面永遠不會被緩存。

<meta http-equiv='cache-control' content='no-cache'> 
<meta http-equiv='expires' content='0'> 
<meta http-equiv='pragma' content='no-cache'> 
+0

我試過這個。很抱歉沒有工作 – Tje123

+0

@ Tje123我可以知道你試過了嗎? –

+0

我試過meta tags.but不知道我想在哪裏放'angular.element('html [manifest = saveappoffline.appcache]')。attr('content','');'? – Tje123

相關問題