2017-08-18 98 views
3

那麼,雖然我開發的測試管理頁面,

微軟邊緣發生了一個奇怪的問題。

這裏的源代碼部分獲取自loginCtrl.js

 $http({ 
      method: 'POST', 
      url: Define.apiUrl + 'admin/login', 
      data: { 
       user_id: $scope.login_email, 
       password: $scope.login_password 
      } 
     }) 
     .then(function (response) { 
      if (response.data.success) { 
       $cookieStore.put(Define.userInfo, response.data.info); 
       $cookieStore.put(Define.userToken, response.data.token); 
      } 
     }, function (data) { 
      console.log('errors!'); 
      console.log(data); 
     }); 

這在Chrome和IE

但在微軟邊緣效果良好的服務器響應,這將返回錯誤一樣低於

data = null 
status = -1 
statusText = "" 

以下是相關文件的狀態。

 # loginCtrl.js 


     ## Chrome response status 

     Accept-Ranges:bytes 
     Cache-Control:public, max-age=0 
     Connection:keep-alive 
     Content-Length:1877 
     Content-Type:application/javascript 
     Date:Fri, 18 Aug 2017 04:06:49 GMT 
     ETag:W/"755-15df385a23e" 
     Last-Modified:Fri, 18 Aug 2017 04:06:47 GMT 


     ## Chrome request status 

     Accept:'*/*' 
     Accept-Encoding:gzip, deflate, br 
     Accept-Language:ko-KR,ko;q=0.8,en-US;q=0.6,en;q=0.4 
     Connection:keep-alive 
     Host:localhost:9000 
     If-Modified-Since:Fri, 18 Aug 2017 02:51:00 GMT 
     If-None-Match:W/"6f5-15df340413d" 
     Referer:http://localhost:9000/ 
     User-Agent:Mozilla/5.0 (Windows NT 10.0; Win64; x64) 
     AppleWebKit/537.36 (KHTML, like Gecko) 
     Chrome/60.0.3112.101 Safari/537.36 


     ## Edge response status 

     Accept-Ranges: bytes 
     Cache-Control: public, max-age=0 
     Connection: keep-alive 
     Content-Length: 1807 
     Content-Type: application/javascript 
     Date: Fri, 18 Aug 2017 02:06:14 GMT 
     ETag: W/"70f-15df3173adf" 
     Last-Modified: Fri, 18 Aug 2017 02:06:12 GMT 


     ## Edge request status 

     Accept: application/javascript, '*/*'; q=0.8 
     Accept-Encoding: gzip, deflate 
     Accept-Language: ko-KR 
     Connection: Keep-Alive 
     Host: localhost:9000 
     Referer: http://localhost:9000/ 
     User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) 
     AppleWebKit/537.36 (KHTML, like Gecko) 
     Chrome/52.0.2743.116 Safari/537.36 Edge/15.15063 

我想知道爲什麼只有Edge無法得到正確的迴應。

我試着製作'Content-Type','Cache-Control'或像cache:false這樣的配置。

但這些無法解決這個問題。

我錯過了什麼?

PLZ任何帥還是蠻程序員救救我

+1

您在響應標題中的內容類型是text/css?您是否使用Edge調試服務器上的請求和響應?我幾乎認爲Content-Type與您的錯誤有關。 –

+0

@VuQuyet哦我的..我帶來的是錯誤的狀態.. Thx現在我糾正 –

回答

1

我試圖找到這個解決方案,最後我得到了一個。

一些答案建議加上標籤,如

<meta http-equiv="Cache-Control" content="no-cache" /> 
<meta http-equiv="Pragma" content="no-cache" /> 
<meta http-equiv="Expires" content="Mon, 26 Jul 1997 05:00:00 GMT" /> 

或添加代碼到config

$httpProvider.defaults.headers.get['If-Modified-Since'] = 'Mon, 26 Jul 1997 05:00:00 GMT'; 
// extra 
$httpProvider.defaults.headers.get['Cache-Control'] = 'no-cache'; 
$httpProvider.defaults.headers.get['Pragma'] = 'no-cache'; 

但這些未能解決這個問題。

最後我看到一個答案,說這可能是由Edge中的一種策略處理緩存發生的。

當我使用本地服務器發送請求或獲取響應時,可能會發生這種情況。

當在其他服務器上不在本地進行測試時,它會消失。

其實,我仍在使用本地服務器,所以我不知道這個工作與否。