2017-10-28 130 views
0

今天,我想爲我的S3存儲桶啓用AWS CloudFront自動壓縮功能,因爲Google PageSpeed Insights建議您這樣做。所以我做了什麼: - 去了雲端,選擇分佈,編輯了行爲設置,啓用了「自動壓縮對象」; - 等待分配重新部署。AWS CloudFront自動壓縮功能不起作用

之後,我檢查了從我的頁面到s3桶的請求。

Request headers: 

:authority:******.com 
:method:GET 
:path:/app.min.js 
:scheme:https 
accept:*/* 
accept-encoding:gzip, deflate, br 
accept-language:ru-RU,ru;q=0.8,en-US;q=0.6,en;q=0.4,da;q=0.2 
cache-control:no-cache 
cookie:_ga=GA1.2.1335221784.1504949270; _gid=GA1.2.1414665009.1509096143 
pragma:no-cache 
referer:https://****.com/index.html 
user-agent:Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36 

Response headers: 

age:1507 
content-length:633168 
content-type:application/javascript 
date:Thu, 26 Oct 2017 10:05:44 GMT 
etag:"45078c31177a2c0aa98e2d97b014841e" 
last-modified:Thu, 26 Oct 2017 09:58:14 GMT 
server:AmazonS3 
status:200 
via:1.1 f96185b1d69d6f85635bc2b5554da639.cloudfront.net (CloudFront) 
x-amz-cf-id:aOflZZwZTvtfNnm2gxOQGKMxZi-MVfuiTw9YhRxswoqU84L84Z3D-Q== 
x-cache:Hit from cloudfront 

看起來像CloudFront的需要做出autocompression工作存在的所有標頭,但無論是要求加載速度更快,也沒有文件的大小減小。 Google PageSpeed Tool仍然建議啓用自動壓縮。 有什麼建議嗎?

回答

0

問題已解決。我必須使發佈的雲端緩存無效,因爲cloudfront不會壓縮已存在於緩存中的對象。