有人能走我经由S3原点服务gzip压缩的文件从的Cloudfront?原点、能走、文件、Cloudfront

2023-09-11 08:44:03 作者:坚强,是你唯一的出路。

我已经通过从上的StackOverflow其他职位这个话题给出了不少建议,但我仍然没有成功得到它的工作。

I've been through quite a few suggestions given on this topic from other posts on Stackoverflow, but I'm still not successfully getting it to work.

网站起源是在S3上,它是通过的Cloudfront被服务。经过其他职位和亚马逊的文档,我看到如建议:

The website origin is on S3, it is being served via Cloudfront. Going through the other posts and Amazon docs, I'm seeing suggestions such as:

1)GZIP必要的文件,删除文件名。广州,但上载,仍设置荟萃于gzip。这不是为我工作。 Safari浏览器只是下载,而不是作为一个网页上的gzip压缩文件(S)。

1) Gzip the necessary files, remove the .gz from the files name, but on uploading, still set the meta to gzip. This isn't working for me. Safari just downloads the gzipped file(s) instead of serving as a webpage.

2)亚马逊文档建议您上传既gzip压缩的文件没有-COM pressed版本,但它没有提到,如何工作的。例如,你链接到双方的style.css和style.css.gz在网站HTML?如果是这样,就是不击败gzip压缩,以加快该网站的对象,因为它似乎两个请求将作出,而不是一个?

2) Amazon docs suggest uploading both a gzipped and none-compressed version of the file, but it makes no reference as to how that works. For example, do you link to both style.css and style.css.gz in the sites html? If so, is that not defeating the object of gzipping to speed up the site as it seems two requests would be made instead of one?

此外,当您设置文档的Cloudfront是为了获取,如index.html的,如果您有一个压缩和非COM pressed文件,你设置为文件检索?当我设置文档作为index.html.gz,浏览器只是再次下载该文件。

Also, when you set the document Cloudfront is meant to retrieve, e.g. index.html, if you have both a gzipped and non-compressed file, which do you set as the document to retrieve? When I set the document as index.html.gz, the browser again just downloads the file.

我收到速度收视率在70%-80%的利润,这,公平并可能会更糟,但它可能会更好过。我不是一个初学者,但我是一个百万英里的距离作为一个专家在这个东西,所以我希望我能得到一步步走过就在这里。一定有什么东西我没有得到完全正确。

I'm getting speed ratings in the 70-80% margins, which, fair does could be worse, but it could be better too. I'm not a beginner, but I'm a million miles away from being an expert at this stuff, so I'm hoping I can get a step by step walk through on here. There must be something I'm not getting quite right.

在此先感谢您的帮助。

推荐答案

这个过程应该是这样的:

The process should look like this:

本地gzip压缩的文件(那么它应该被称为 index.html.gz ) 删除。广州扩展(现在文件名为 index.html的但内容gzip压缩) 将文件上传到S3 在设置在S3管理控制台文件的元数据标签的正确内容类型基于它是什么文件和 设置内容编码 GZIP gzip the file locally (it should then be called index.html.gz) remove the .gz extension (file is now called index.html but content is gzipped) upload the file to S3 in the metadata tab for the file in the S3 management console set the correct Content-Type based on what file it is and set Content-Encoding to gzip

当连接到您的HTML标记一个压缩样式表只需指定名称而不。广州扩展。

When linking to a gzipped stylesheet in your HTML markup just specify the name without the .gz extension.

一个不错的网站,以测试配置的工作原理是 http://gzipwtf.com/

A great site to test if the configuration works is http://gzipwtf.com/

另外不要忘了无效的CloudFront的缓存,如果你把它用在该文件被缓存。

Also don’t forget to invalidate the CloudFront cache if the file you’re trying it out with is cached.

编辑:

要不要用手摆弄这些东西所有的时间,我建议你自动上传并设置标题的过程中某种构建过程中。 s3_website 是一个很好的Ruby宝石上手,但也有其他命令行工具或可咕噜的插件以及。

To not fiddle around with this stuff by hand all the time I suggest you automate the process of uploading and setting headers in some kind of build process. s3_website is a nice Ruby gem to get started but there are other command line tools or Grunt plugins available as well.

 
精彩推荐