PageSpeed and CDN images
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?
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.
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