簡體   English   中英

Cloudfront 緩存控制標頭丟失

[英]Cloudfront cache-control headers missing

我設置 Cloudfront 為 www.lottoresults.ie 提供 static 個圖像、js、css 個文件。 我使用了自定義源服務器。

我設置的雲端域名是icdn.lottoresults.ie。 我使用 Bind9 dns 和 icdn.lottoresults.ie 為雲端發行版設置了一個 CNAME。

沒關系。

但是,對於網站性能優化(Yslow、google pagespeed 等),我想要設置 Cache-control 和 Expires 標頭,並且我不想要 Etags。

為此,我在 www.lottoresults.ie 的 doc_root 的 my.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>

問題是對於來自雲端發行版 (icdn) 的資產,我沒有 Cache-control 或 Expires 標頭,但我有 Etags - 但對於 www 我確實有 Cache-control 和 Expires 標頭,但沒有 Etags。

當我從我的雲端域查詢資產時,我沒有 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

然而,當我從我的源服務器查詢相同的資產時,我得到以下信息,其中包括緩存控制、過期,但沒有 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

非常感謝任何幫助或建議。

謝謝保羅

對於可能有同樣問題的任何其他人,我想我知道這是什么。

這是一種PEBKAC - 我必須在資產獲得新標頭之前使資產無效

例如,我添加了一個新文件 images/zoom2.gif,它看起來是正確的:

curl -I -L http://icdn.lottoresults.ie/images/zoom2.gif

HTTP/1.0 200 OK
Date: Fri, 06 Apr 2012 23:00:24 GMT
Server: Apache/2.2.9 (Debian) PHP/5.2.6-1+lenny13 with Suhosin-Patch
Accept-Ranges: bytes
Content-Length: 1849
Cache-Control: max-age=1864000, public
Expires: Sat, 06 Apr 2013 23:00:24 GMT
Content-Type: image/gif
Age: 29
X-Cache: Hit from cloudfront
X-Amz-Cf-Id:         vPPBdJpw0ZI_J2trHyECnE2UBeQO9NsQZD9GSvl3GIVAZuQN5lz1ZQ==,J4bBHfF5lKEpjRPLZVYpS9HUdAKEOLEe-Gy3-a_x4PsLPrdWuRg93Q==
Via: 1.0 00204466f749ba432b50dc49d604c534.cloudfront.net (CloudFront)
Connection: close

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM