【发布时间】:2012-04-06 21:16:56
【问题描述】:
我设置 Cloudfront 为 www.lottoresults.ie 提供静态图像、js、css 文件。我使用了自定义源服务器。
我设置的云端域名是icdn.lottoresults.ie。我使用 Bind9 dns 进行了设置,其中 icdn.lottoresults.ie 是 Cloudfront 发行版的 CNAME。
没关系。
但是,对于网站性能优化(Yslow、google pagespeed 等),我想要设置 Cache-control 和 Expires 标头,并且我不想要 Etags。
为此,我在我的 htaccess 文件中为 www.lottoresults.ie 的 doc_root 提供了以下内容:
Header unset Pragma
FileETag none
Header unset ETag
<FilesMatch "(.*)\.(ico|jpg|jpeg|png|gif|js|css|swf)$">
ExpiresActive on
ExpiresDefault "access plus 1 year"
Header set Cache-Control "max-age=1864000, public"
Header unset Last-Modified
</FilesMatch>
问题是,对于来自云端发行版 (icdn) 的资产,我没有 Cache-control 或 Expires 标头,但我有 Etags - 但对于www 我确实有 Cache-control 和 Expires 标头,但没有 Etag。
当我从我的云端域查询资产时,我没有 Cache-control 或 Expires 标头,但我有 Etags。
curl -I -L http://icdn.lottoresults.ie/images/green-header.jpg
HTTP/1.0 200 OK
Date: Sun, 01 Apr 2012 22:58:30 GMT
Server: Apache/2.2.9 (Debian) PHP/5.2.6-1+lenny13 with Suhosin-Patch
Last-Modified: Mon, 08 Aug 2011 20:23:00 GMT
**ETag**: "28a213-19b-4aa0436a1b100"
Accept-Ranges: bytes
Content-Length: 411
Content-Type: image/jpeg
Age: 22137
X-Cache: Hit from cloudfront
X-Amz-Cf-Id: AV55dR4_vWHtlTbU6E9M2tkh9reoAwZcHlD4y9csetK6B6Ey8gDPJA=
Via: 1.0 8adf6ec3585d73c680b4a6d5052988d8.cloudfront.net (CloudFront)
Connection: close
然而,当我从源服务器查询相同资产时,我得到以下信息,其中包括缓存控制、过期和无 Etag。
curl -I -L http://www.lottoresults.ie/images/green-header.jpg
HTTP/1.1 200 OK
Date: Fri, 06 Apr 2012 20:50:08 GMT
Server: Apache/2.2.9 (Debian) PHP/5.2.6-1+lenny13 with Suhosin-Patch
Accept-Ranges: bytes
Content-Length: 411
**Cache-Control**: max-age=1864000, public
**Expires**: Sat, 06 Apr 2013 20:50:08 GMT
Content-Type: image/jpeg
非常感谢任何帮助或建议。
谢谢 保罗
【问题讨论】:
标签: apache cache-control amazon-cloudfront