2015-11-04 54 views
2

這是一個有關多域訪問chrome中相同服務器文件的問題。CORS訪問控制 - 允許源緩存問題

=========

服務器:Apache(支持CORS

文件URL:www.a.com/a.file

多域: b.com,c.com ...

=========

情況:(鉻)

  1. b.com access a.file:success

    然後c.com訪問a.file:失敗

  2. b.com訪問a.file:成功。

    然後清潔緩存,

    c.com訪問a.file:成功

  3. b.comHTTP訪問a.file: 成功

    ,然後用HTTPSb.com訪問a.file:失敗(如1)

  4. b.com訪問a.file與HTTP成功

    然後乾淨高速緩存鉻的

    b.com訪問a.file與HTTPS失敗(如2)

在情況1中,這裏是請求頭。並且我注意到請求將從緩存中訪問文件,並且訪問控制允許來源都是http://www.b.com。也許這是這個問題的關鍵。但我不知道......

b.com

Request URL:www.a.com/a.file 
Request Method:GET 
Status Code:200 OK (from cache) <-here 

Response Headers 
Accept-Ranges:bytes 
Access-Control-Allow-Methods:GET, POST 
Access-Control-Allow-Origin:http://www.b.com <--(here! the same as situation 2) 
Content-Length:115 
Content-Type:text/plain 
Date:Wed, 04 Nov 2015 10:21:29 GMT 
Last-Modified:Tue, 28 Jul 2015 01:41:20 GMT 
Server:Apache 

℃。com

Request URL:www.a.com/a.file 
Request Method:GET 
Status Code:200 OK (from cache) <-here 

Response Headers 
Accept-Ranges:bytes 
Access-Control-Allow-Methods:GET, POST 
Access-Control-Allow-Origin:http://www.b.com <--(here! it is "http://www.a.com" in situation 2) 
Content-Length:115 
Content-Type:text/plain 
Date:Wed, 04 Nov 2015 10:21:29 GMT 
Last-Modified:Tue, 28 Jul 2015 01:41:40 GMT 
Server:Apache 

回答

4

問題解決了。

只需要添加頭文件將Vary Origin附加到Apache的httpd.conf中。

here是細節。

+0

您是否將此添加到'a.com''b.com'或'c.com'的conf中?文件所屬的a.com上的 –

+0

。 –

+0

謝謝!需要檢查一下我正在做的事情:) –