简体   繁体   English

网站图像优化-mod_pagespeed X批量优化和替换源代码(trimage)

[英]Image optimization for Websites - mod_pagespeed X bulk optimize and replace source (trimage)

I have a couple of wordpress websites running on nginx with ngx_pagespeed (same as mod_pagespeed). 我有几个在ngx_pagespeed(与mod_pagespeed相同)上在nginx上运行的wordpress网站。 It optimizes css, js, html and images and serve optimized resources from ram cache. 它优化了css,js,html和图像,并从ram缓存提供了优化的资源。

So I am considering moving all media to another domain/server (amazon S3). 因此,我正在考虑将所有媒体移至另一个域/服务器(amazon S3)。 Problem is with that I will loose the ngx_pagespeed optimization. 问题是我将放松ngx_pagespeed优化。

What are my options? 我有什么选择? What do you guys think about cli optimize and replace source images before moving them to s3? 你们如何看待cli优化并替换源图像,然后再将其移至s3? Maybe a tool like Trimage would do the trick. 也许像Trimage这样的工具可以解决问题。

Another problem is these websites are feed by their owners so I cannot control image optimization pre upload. 另一个问题是这些网站由其所有者提供,因此我无法控制图像优化的预上传。 All i can do is either optimize with mod_pagespeed or bulk optimize before moving to S3. 我所能做的就是在使用S3之前使用mod_pagespeed进行优化或批量优化。

What do you guys think? 你们有什么感想? Anyone has came across a similar problem before? 有人遇到过类似的问题吗?

Best regards. 最好的祝福。

One is solution that gets you the best of both worlds is to use a CDN that supports origin pull, like Amazon CloudFront , and configuring the ModPagespeedMapRewriteDomain option in mod_pagespeed (see the section on Mapping Rewrite Domains). 一种使您两全其美的解决方案是使用支持起源拉取的CDN(例如Amazon CloudFront) ,并在mod_pagespeed中配置ModPagespeedMapRewriteDomain选项(请参阅“映射重写域”部分)。

This works as such. 这样工作。 When you configure the MapRewriteDomain option, you'll set it up so that mod_pagespeed will change the URL of optimized resources (images, js, etc.) to use the CDN's domain. 配置MapRewriteDomain选项时,将对其进行设置,以便mod_pagespeed将更改优化资源(图像,js等)的URL以使用CDN的域。 When the CDN receives a request for a resource it doesn't have, it will fetch it from the origin domain, and cache it (this is the origin pull feature). 当CDN收到对它没有的资源的请求时,它将从原始域中获取它,并对其进行缓存(这是原始拉取功能)。 That way you'll be able to get the benefits of both a CDN for your static resources, and mod_pagespeed's resource optimization features. 这样一来,您既可以为静态资源获得CDN的好处,又可以获得mod_pagespeed的资源优化功能。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM