我设置Cloudfront为www.lottoresults.ie提供静态图像,js,css文件。我使用了一个自定义源服务器。Cloudfront缓存控制标头丢失
我设置的云端域名是icdn.lottoresults.ie。我使用Bind9 dns进行设置,icdn.lottoresults.ie是cloudfront发行版的CNAME。
这一切都很好。
但是,对于网站性能优化(Yslow,谷歌pagespeed等),我想有缓存控制和过期头设置,我不想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>
问题是从CloudFront的发行版(ICDN)未来资产, 我没有缓存控制或过期头,但我有Etags - 但对于www,我确实有缓存控制和过期头,没有Etags。
当我从我的云前端域查询资产时,我没有缓存控制或过期标题,但我确实有Etags。
卷曲-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时。
卷曲-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
任何帮助或建议,不胜感激。
感谢 保罗
+1与您的解决方案跟进,谢谢! – 2012-04-07 16:52:55
感谢您发布您的解决方案,它也帮助我! – 2013-03-17 15:16:55
网址不再有效。 =( – 2015-03-25 21:41:10