我设置了Cloudfront来提供www.lottoresults.ie的静态图片、js和css文件,并使用自定义源服务器。
我设置的Cloudfront域名是icdn.lottoresults.ie。我使用Bind9 DNS进行设置,将icdn.lottoresults.ie作为Cloudfront分发的CNAME。
这一切都很好。 但是,为了网站性能优化(Yslow、谷歌页面速度等),我想设置Cache-control和Expires头,并且不想使用Etags。
为此,我在www.lottoresults.ie的doc_root的htaccess文件中添加了以下内容:
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>
问题是,针对来自CloudFront分发(icdn)的资源,我没有缓存控制或过期标头,但我确实有ETags - 但对于www,我确实具有Cache-control和Expires标头,并且没有ETags。
当我从我的CloudFront域查询资产时,我没有缓存控制或过期标头,但我确实有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
然而,当我从我的源服务器查询相同的资产时,我得到了以下结果,其中包括Cache-control、Expires和没有Etags。
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
任何帮助或建议都将不胜感激。谢谢。 保罗