gpt4 book ai didi

apache - CORS Access-Control-Allow-Origin 缓存问题

转载 作者:行者123 更新时间:2023-12-02 03:21:20 25 4
gpt4 key购买 nike

这是chrome中多域访问同一个服务器文件的问题。

========

服务器:apache(支持CORS)

文件网址:www.a.com/a.file

多域名:b.com、c.com ...

========

情况:(在 Chrome 中)

  1. b.com 访问 a.file :成功

    然后c.com访问a.file:失败

  2. b.com 访问 a.file:成功。

    然后清理 Chrome 缓存

    c.com访问a.file:成功

  3. b.com使用http访问a.file:成功

    然后b.com使用https访问a.file:失败(如1)

  4. b.com 使用 http 访问 a.file :成功

    然后清理 Chrome 缓存

    b.com使用https访问a.file:失败(如2)

在情况1中,这是请求 header 。我注意到该请求将从缓存访问文件,并且两个 Access-Control-Allow-Origin 都是 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

c.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

最佳答案

问题已解决。

只需在 Apache 的 httpd.conf 中添加 Header Append Vary Origin 即可。

here就是细节。

关于apache - CORS Access-Control-Allow-Origin 缓存问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33521714/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com