【问题标题】:Leverage browser caching Using S3 Amzon利用浏览器缓存 使用 S3 Amazon
【发布时间】:2014-02-23 08:16:50
【问题描述】:

我已上传图像并为我的 S3 Amazon 帐户设置了过期标头。 示例:http://d2aj9ttnhtlit4.cloudfront.net/mt/carrusel/elige-tu-destino.jpg 当我检查图像标题时,它显示:

HTTP/1.1 200 OK => 
Content-Type => image/jpeg
Content-Length => 5389
Connection => close
Date => Wed, 29 Jan 2014 15:53:12 GMT
Cache-Control => max-age=2628000
Expires => Sun, 15 Feb 2015 12:00:00 GMT
Last-Modified => Wed, 29 Jan 2014 15:44:31 GMT
ETag => "16d47fedbba7aedc3e3d454baf1d6f8f"
Accept-Ranges => bytes
Server => AmazonS3
Age => 101140
X-Cache => Hit from cloudfront
Via => 1.1 a7659acb73506d9cdaa5e4d5e6f0ba0b.cloudfront.net (CloudFront)
X-Amz-Cf-Id => 1e7GVW-p4nj88gUBDzVfJnUPzyODHV2pBo1_xFTK67PIqFNuzXRriQ==

...如果我运行页面速度测试,我会收到错误:

将浏览器缓存用于以下可缓存资源: http://d2aj9ttnhtlit4.cloudfront.net/mt/carrusel/elige-tu-destino.jpg(未指定过期时间)

对于我 S3 中的所有静态图像

如果在标头中设置了过期,这怎么可能?

你能帮我理解吗?谢谢。

【问题讨论】:

标签: caching pagespeed


【解决方案1】:

当我运行 PageSpeed Insights 时,该图像没有显示:https://developers.google.com/speed/pagespeed/insights/?url=http%3A%2F%2Fwww.megatravel.com.mx%2F

相反,我的运行表明您需要利用浏览器缓存:

http://d2aj9ttnhtlit4.cloudfront.net/logo-mega-travel.png(未指定过期时间) http://static.mtmedia.com.mx/mt/carrusel/elige-tu-destino.jpg(未指定过期时间) http://static.mtmedia.com.mx/mt/carrusel/viajes-a-europa.jpg(未指定过期时间) http://static.mtmedia.com.mx/mt/carrusel/viajes-a-medio-oriente.jpg(未指定过期时间) http://static.mtmedia.com.mx/mt/carrusel/viajes-a-sudamerica.jpg(未指定过期时间) http://static.mtmedia.com.mx/mt/carrusel/viajes-africa.jpg(未指定过期时间) http://static.mtmedia.com.mx/mt/carrusel/viajes-al-pacifico.jpg(未指定过期时间) http://static.mtmedia.com.mx/mt/carrusel/viajes-asia.jpg(未指定过期时间) http://static.mtmedia.com.mx/mt/carrusel/viajes-canada.jpg(未指定过期)

看看logo-mega-travel.png,它似乎没有Cache-Control 标头,所以这看起来很准确……但看起来其他人确实有有效的Cache-Control 标头,所以不清楚PageSpeed 抱怨它们的原因.

请注意,PageSpeed Insights 在线工具会在短时间内缓存测试您网站的结果,因此如果您只是将 Cache-Control 标头添加到其他资源,则可能需要一些时间来更新。

【讨论】:

    猜你喜欢
    • 2016-12-06
    • 2011-10-15
    • 2014-07-18
    • 1970-01-01
    • 2016-03-13
    • 2017-09-05
    相关资源
    最近更新 更多