【问题标题】:CloudFront image cache-control headersCloudFront 图像缓存控制标头
【发布时间】:2011-10-28 05:02:41
【问题描述】:

1- 这是一个有效的缓存控制头吗:

Cache-Control: max-age=86400, s-maxage=3600

2- 我正在尝试为从 S3 通过 CloudFront 提供的对象设置缓存控制标头。图像不经常改变,但有时可以。这似乎是一个很好的缓存控制吗? CloudFront 应每 60 分钟重新验证一次,但用户将缓存一整天。 (我不太担心单个用户,而更担心继续为新用户提供陈旧的图像)。

3- 还有其他我应该使用的标题吗? (即代理重新验证)

在 S3 对象上更改这些设置并非易事,因此我试图在第一时间就正确处理。谢谢。

【问题讨论】:

    标签: header amazon-s3 cache-control amazon-cloudfront


    【解决方案1】:

    我只是让它与两者一起工作

    1. Access-control-Max-Age(在 S3 CORs 设置中设置)
    2. 缓存控制
    3. 过期

    理论上,从 AWS S3 / Cloudfront 文档来看,只有 1. 可以工作。在实践中,两者都需要。

    基思

    【讨论】:

      【解决方案2】:

      这是我要工作的内容:

      Cache-Control: max-age=29030400, public
      Expires: Wed, 30 Dec 2015 18:00:00 GMT
      

      理论上,您只需要其中一个。但是整个浏览器缓存与 S3 和 CloudFront 的关系一直让我感到很痛苦,所以我喜欢将它们都保留在那里。我还在我的.htaccess 文件中添加了以下内容:

      # BEGIN Caching
      Header set Cache-Control "max-age=29030400, public"
      <IfModule mod_expires.c>
          ExpiresActive On
          ExpiresDefault "access plus 1 year"
          ExpiresByType text/css "access plus 1 year"
          ExpiresByType text/plain "access plus 1 year"
          ExpiresByType image/gif "access plus 1 year"
          ExpiresByType image/png "access plus 1 year"
          ExpiresByType image/jpeg "access plus 1 year"
          ExpiresByType application/x-javascript "access plus 1 year"
          ExpiresByType application/javascript "access plus 1 year"
          ExpiresByType application/x-icon "access plus 1 year"
      </IfModule>
      # END Caching
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2019-03-26
        • 2011-01-13
        • 2011-07-06
        • 2011-10-08
        • 2017-01-10
        • 2012-04-26
        • 2013-08-17
        • 2010-10-31
        相关资源
        最近更新 更多