PageSpeed and CDN images

怎甘沉沦 提交于 2019-12-08 10:40:17

问题


I currently have a site that services images located on AWS S3 via AWS Cloudfront.

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.

My question is:

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?

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/;

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?

thankyou Adam

EDIT: I can now see the following:

pagespeed LoadFromFileMatch "^https?://example.com/~([^/]*)/static/"
                            "/var/www/static/\\1";

It appears this might allow PageSpeed to check for local resources and then fetch from a remote HTTP location if required.


回答1:


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;

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;

This will tell mod_pagespeed to change the domain the rewritten resources are served from so that you can actually serve the rewritten versions.

For more information see https://developers.google.com/speed/pagespeed/module/domains



来源:https://stackoverflow.com/questions/26132351/pagespeed-and-cdn-images

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!