導航:首頁 > 源碼編譯 > angular8編譯緩存

angular8編譯緩存

發布時間:2023-05-21 02:51:55

❶ angularjs路由如何禁止緩存

angular默認的模板載入都會被緩存起來,使用的緩存服務是$tempalteCache,發送模板請求的服務是$templateRequest,可以有兩種方案:搭運
1.每次發送$http請求模板完成後,調用$tempalteCache.remove(url)或removeAll清除所有模板緩存;
2.使用$provide.decorator改寫原生的$templateRequest,禁掉緩存笑枝拆,$templateRequest的源碼,可以看到它默認使用$tempalteCache作為緩存,可以去掉它碰棗。

❷ 如何解決AngularJs在IE下取數據總是緩存的問題

如果用AngularJs在IE下發出GET請求模行從後台服務取完Json數據再綁定到頁面上顯示的話,你可能會發現就算數據更新了,IE還是會顯示原來的結果。實際上這時候IE的確是緩存了hashtag,沒有再次去做HttpGET請求最新的數據。x0dx0a最直接的辦法是在後台擼掉OutputCache,但這種做法余模並不推薦,需要改每一處被Angular調用的地方,代價太大。這種問題應該在前端解決最好。研究了一會兒總結了最有效的旦毀嘩解決方法,並不需要改後台代碼了。x0dx0a在你的appconfig里擼一個$httpProvider進去,比如像我這樣,和路由可以配在一起,當然分開配也沒問題。x0dx0avarconfig=["$routeProvider","$httpProvider",function($routeProvider,$httpProvider){x0dx0a//(!$httpProvider.defaults.headers.get){x0dx0a$httpProvider.defaults.headers.get={};x0dx0a}x0dx0a//EnablesRequest.IsAjaxRequest()inASP.NETMVCx0dx0a$httpProvider.defaults.headers.common["X-Requested-With"]='XMLHttpRequest'x0dx0a//$httpProvider.defaults.headers.get['Cache-Control']='no-cache'x0dx0a$httpProvider.defaults.headers.get['Pragma']='no-cache'x0dx0a$routeProvider.when("/",{templateUrl:"Manage/dashboard/index.cshtml"})x0dx0a.when("/dashboard",{templateUrl:"Manage/dashboard/index.cshtml"})x0dx0a.when("/dashboard/serverinfo",{templateUrl:"Manage/dashboard/serverinfo.cshtml"})x0dx0a.when("/dashboard/emaillogs",{templateUrl:"Manage/dashboard/emaillogs.cshtml"})x0dx0a//othercode....x0dx0a.otherwise({redirectTo:"/"});x0dx0a}];x0dx0aapp.config(config);x0dx0ax0dx0a最關鍵的就是最後的禁用IE對ajax的緩存x0dx0a$httpProvider.defaults.headers.get['Cache-Control']='no-cache'x0dx0a$httpProvider.defaults.headers.get['Pragma']='no-cache'x0dx0ax0dx0a如果你想這樣寫,是會爆的:x0dx0a$httpProvider.defaults.headers.get['If-Modified-Since']=Ɔ'x0dx0ax0dx0a這樣會導致include指令載入的partialview擼不出來,所以不要作死了

閱讀全文

與angular8編譯緩存相關的資料

熱點內容
網盤忘記解壓碼怎麼辦 瀏覽:852
文件加密看不到裡面的內容 瀏覽:651
程序員腦子里都想什麼 瀏覽:430
oppp手機信任app在哪裡設置 瀏覽:185
java地址重定向 瀏覽:268
一年級下冊摘蘋果的演算法是怎樣的 瀏覽:448
程序員出軌電視劇 瀏覽:88
伺服器系統地址怎麼查 瀏覽:54
解壓游戲發行官 瀏覽:601
國外小伙解壓實驗 瀏覽:336
頂級大學開設加密貨幣 瀏覽:437
java重載與多態 瀏覽:528
騰訊應屆程序員 瀏覽:942
一鍵編譯程序 瀏覽:129
語音加密包哪個好 瀏覽:340
有什麼學習高中語文的app 瀏覽:282
安卓手機的表格里怎麼打勾 瀏覽:411
阿里雲伺服器有網路安全服務嗎 瀏覽:970
超解壓兔子視頻 瀏覽:24
單片機怎麼測負脈沖 瀏覽:174