導航:首頁 > 源碼編譯 > 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編譯緩存相關的資料

熱點內容
qq可以加密密碼 瀏覽:854
網上認證無法連接網站伺服器地址 瀏覽:920
java資料庫建表 瀏覽:172
linux本地埠 瀏覽:36
郵票目錄pdf 瀏覽:378
解壓筆真的有用嗎 瀏覽:538
plc語法和編程語句 瀏覽:115
南航app學生旅行產品在哪裡 瀏覽:240
漫畫pdf網盤 瀏覽:495
手機pdf字太小 瀏覽:892
解壓縮安裝圖解 瀏覽:257
安卓如何查看運行伺服器 瀏覽:681
土質學pdf 瀏覽:995
郵箱收發伺服器地址 瀏覽:143
web前端和python 瀏覽:639
定址演算法 瀏覽:783
車床編程ijk之間的關系 瀏覽:493
安卓什麼app可以訪問smb 瀏覽:205
籠統概括程序員 瀏覽:853
linuxfdiskdf 瀏覽:300