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

熱點內容
dhcp伺服器新增地址 瀏覽:930
程序員跑三個月外賣 瀏覽:941
linux配置tomcat的jdk路徑 瀏覽:363
液體壓縮公式 瀏覽:777
php開發後台管理系統 瀏覽:360
python二分查找遞歸 瀏覽:447
微信如何發視頻不壓縮 瀏覽:902
河北2021美術高考綜合分演算法 瀏覽:606
如何為電腦文件夾加密 瀏覽:835
電腦自啟動應用命令 瀏覽:690
php判斷一個文件是否存在 瀏覽:829
php導出xml文件 瀏覽:904
7個文件夾解壓 瀏覽:383
python實現機器碼 瀏覽:356
jpeg壓縮器 瀏覽:98
php數組轉化json 瀏覽:33
轉換mp3用什麼app 瀏覽:465
國際服吃雞為什麼沒有提供伺服器 瀏覽:494
單片機中斷定時 瀏覽:395
像搭積木一樣的編程叫什麼編程 瀏覽:804