代码之家  ›  专栏  ›  技术社区  ›  pr1001

WebKIT缓存第三方资源吗?

  •  1
  • pr1001  · 技术社区  · 15 年前

    在Chrome和Safari中,虽然服务器返回了适当的信息,但我的站点中包含的远程映像似乎从未被请求缓存友好的头文件(如果修改自等)。另一方面,本地资源是通过这些头请求的。相比之下,火狐通过缓存友好的头来请求远程资源。

    这是S3上的图像,虽然我不认为它是S3的唯一…

    更新: Here's the actual request I'm seeing via Chrome Resources panel.

    Request URL:http://mobtest.s3.amazonaws.com/4MKHZL-114.png
    Request Method:GET
    Status Code:200 OK
    

    请求报头

    Accept:application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
    Cache-Control:max-age=0
    Referer:http://mobtest.s3.amazonaws.com/4MKHZL-114.png
    User-Agent:Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_4; en-US) AppleWebKit/533.4 (KHTML, like Gecko) Chrome/5.0.375.86 Safari/533.4
    

    Response Headers

    Cache-Control:public, max-age=86400
    Content-Length:4074
    Content-Type:image/png
    Date:Wed, 30 Jun 2010 12:15:42 GMT
    ETag:"7e4739d5527ada6bb327f1e27ee656ef"
    Last-Modified:Tue, 29 Jun 2010 13:40:08 GMT
    Server:AmazonS3
    x-amz-id-2:MKTS28Zu4zTsWFjXUTzvmRY214TO9LTKTxtgW1psWKa/JY2pnwmO9rxs8fyHd/O/
    x-amz-request-id:F6047ADD0FD6D885
    x-amz-version-id:O2OTsDbU4uKOwze7rbK_Do39U_Xhpnyp
    

    Status: 304 Not Modified
    

    Response Headers

    x-amz-id-2  IbhwfAP7FhIN7jtn2FrsjOkVZ8sIKJjv5llevKgw04y2xM+29GSFdGyQNXjiBaMY
    x-amz-request-id    258F30A4CC2AC870
    Date    Wed, 30 Jun 2010 12:19:55 GMT
    Cache-Control   public, max-age=86400
    Last-Modified   Tue, 29 Jun 2010 13:40:08 GMT
    x-amz-version-id    O2OTsDbU4uKOwze7rbK_Do39U_Xhpnyp
    Etag    "7e4739d5527ada6bb327f1e27ee656ef"
    Content-Type    image/png
    Content-Length  4074
    Server  AmazonS3
    

    请求报头

    Host    mobtest.s3.amazonaws.com
    User-Agent  Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.1.7) Gecko/20091221 Firefox/3.5.7
    Accept  text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
    Accept-Language en-us,en;q=0.5
    Accept-Encoding gzip,deflate
    Accept-Charset  ISO-8859-1,utf-8;q=0.7,*;q=0.7
    Keep-Alive  300
    Connection  keep-alive
    If-Modified-Since   Tue, 29 Jun 2010 13:40:08 GMT
    If-None-Match   "7e4739d5527ada6bb327f1e27ee656ef"
    Cache-Control   max-age=0
    

    更新2: 现在我看到Chrome正在缓存内容。奇怪…I'm going to close this question and give Marc the answer.

    1 回复  |  直到 15 年前
        1
  •  1
  •   Community CDub    8 年前

    If the server is sending back an "Expires" header that is somewhat far in the future, then the browser may be deciding that the content is still fresh enough in it's cache and that they don't even need to make a request to the server at all. You may want to review the headers being sent back from the server and ensure they are set to reasonable values. 见 ETag vs Header Expires 更多信息。请随时用从服务器发回的实际URL或邮件头更新您的问题。