PageSpeed和CDN图像 [英] PageSpeed and CDN images
问题描述
我目前有一个站点,该站点通过AWS Cloudfront为位于AWS S3上的图像提供服务.
I currently have a site that services images located on AWS S3 via AWS Cloudfront.
我不想安装PageSpeed,我想利用PageSpeed提供的图像优化和延迟加载(页面外视图)优势.
I'm not looking to install PageSpeed and I want to take advantage of the image optimization and lazy loading (out of page view) that PageSpeed offers.
我的问题是:
我是否需要使用PageSpeed将图像从S3移到服务器上,以利用图像优化和延迟加载的优势.例如:图像需要位于PageSpeed的安装位置,还是在这种情况下可以位于S3的外部?
Do I need to move the images from S3 onto the Server with PageSpeed to take advantage of the image optimization and lazy loading. eg: to the images need to be local to where PageSpeed is installed or can they be external on S3 in this case?
我可以看到如何将pagespeed定向到文件系统中的加载文件(图像),如下所示.
I can see how to direct pagespeed to loadfiles (images) from the file system as below.
pagespeed LoadFromFile http://static.example.com/ /var/www/static/;
答案是否定的,因为将图像放在本地并使用"LoadFromFile"会更快,但是可以使用远程存储库吗?
Would the answer to this be it would be faster to have the images local and use "LoadFromFile" but it's possible to use a remote repository?
谢谢 亚当
我现在可以看到以下内容:
I can now see the following:
pagespeed LoadFromFileMatch "^https?://example.com/~([^/]*)/static/"
"/var/www/static/\\1";
看来,这可能使PageSpeed可以检查本地资源,然后根据需要从远程HTTP位置获取.
It appears this might allow PageSpeed to check for local resources and then fetch from a remote HTTP location if required.
推荐答案
mod_pagespeed可以从任何地方优化图像.默认情况下,它仅优化与HTML相同的域中的图像,您可以使用以下方法授权mod_pagespeed来优化来自任何域的图像:
mod_pagespeed can optimize images from anywhere. By default, it optimizes images only from the same domain as the HTML, you can authorize mod_pagespeed to optimize images from any domain with:
pagespeed Domain www.example.com;
注意:这只会告诉mod_pagespeed重写该域上资源的URL.如果example.com
上也未安装mod_pagespeed,这将失败!在这种情况下,您可以使用:
Note: This will just tell mod_pagespeed to rewrite the URLs for resources on that domain. If example.com
does not have mod_pagespeed installed on it as well, this will fail! If that is the case, you can use:
pagespeed MapRewriteDomain modpagespeed.domain.com other.domain.com;
这将告诉mod_pagespeed更改提供重写资源的域,以便您可以实际提供重写版本.
This will tell mod_pagespeed to change the domain the rewritten resources are served from so that you can actually serve the rewritten versions.
有关更多信息,请参见 https://developers.google.com/speed/pagespeed/模块/域
For more information see https://developers.google.com/speed/pagespeed/module/domains
这篇关于PageSpeed和CDN图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!