如何从Amazon S3提供压缩后的资产 [英] How to serve gzipped assets from Amazon S3

查看:123
本文介绍了如何从Amazon S3提供压缩后的资产的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在从Amazon S3提供我所有的静态资产.我想开始使用压缩的组件.我已压缩并确认Amazon正在设置正确的标头.但是,样式未加载.

I am currently serving all of my static assets from Amazon S3. I would like to begin using gzipped components. I have gzipped and confirmed that Amazon is setting the correct headers. However, the styles are not loading.

我是gzipping组件的新手,所以可能我缺少了什么?我在Amazon S3上找不到太多有关此的信息.

I am new to gzipping components, so possibly I am missing something? I can't find too much information about this with Amazon S3.

推荐答案

供以后参考此问题的任何人:

For future reference to anyone else with this problem:

使用Gzip压缩您的组件.然后删除.gz扩展名,仅保留.css或.js扩展名.将文件上传到您的存储桶.

Gzip your components. Then remove the .gz extension leaving only the .css or .js extension. Upload the files to your bucket.

从S3仪表板中,调出刚刚上传的文件的属性.在元数据"标题下,输入以下信息:

From your S3 dashboard, pull up the properties for the file that you just uploaded. Under the 'Metadata' header enter this information:

'content-type'      :  'text/css' or 'text/javascript'
'content-encoding'  :  'gzip'

这些值选项默认情况下(wtf)不可用,因此您必须手动键入它们.

These value options are not available by default (wtf) so you must manually type them.

这篇关于如何从Amazon S3提供压缩后的资产的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆