繁体   English   中英

如何在Amazon S3中使用浏览器缓存?

[英]How to use browser caching with Amazon S3?

我在gtmetrix.com上获得以下内容:

Leverage browser caching    
E (55)
52%
Server  High
What does this mean?
The following cacheable resources have a short freshness lifetime. Specify an expiration at least one week in the future for the following resources:

http://mysite.s3.amazonaws.com/profile.png (expiration not specified)
http://mysite.s3.amazonaws.com/circle.player.css (expiration not specified)
http://mysite.s3.amazonaws.com/main.js (expiration not specified)
http://mysite.s3.amazonaws.com/not.the.skin.css (expiration not specified)
http://cdn-images.mailchimp.com/embedcode/slim-321711.css (expiration not specified)

我猜测mailchimp文件无法修改。 但是,如何为Amazon S3 Cloudfront文件指定浏览器缓存?

通过Amazon Management Console,选择您的文件(或文件夹)。

在此输入图像描述


转到“属性”选项卡,然后单击“元数据”。

在此输入图像描述


最后,将Cache-Control添加到其标头并保存。

在此输入图像描述

您可以使用s3cmd指定header参数! 在将文件上传到s3时。

例如:

s3cmd sync LOCAL_DIRECTORY s3://BUCKET[/PREFIX] --add-header=Cache-Control:max-age=3153600

将文件存储到s3时。 您可以设置将发送到客户端的自定义标头。 在这种情况下,您可以为文件设置Expires标头。

Cloudfront的工作方式略有不同,因为它取决于您的来源。

我对这个问题很幸运。 实际上,在Bucket中上传文件时,您应该会在上传窗口中看到SET DETAILS

单击它并完成它。 您最终会为文件选择SET METADATA

还有其他方法。 这可能对你有帮助。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM