简体   繁体   English

使用Google PageSpeed Insights和Apache mod_pagespeed进行图像优化

[英]Image Optimization Using Google PageSpeed Insights and Apache mod_pagespeed

I'm looking to get as close to a 100/100 page speed score as possible. 我正在寻找尽可能接近100/100页面的速度得分。

The only issue preventing this is images at this point. 防止这种情况的唯一问题是图像。

As seen in the below image, the native image size is 500x500 but rendered at 327x327, the problem is that these images are responsive, so depending on view port they can be anywhere from 210x210 to 500x500. 如下图所示,本机图像尺寸为500x500,但以327x327渲染,问题在于这些图像具有响应性,因此根据视口的不同,它们的大小可以在210x210至500x500之间。 Google is crawling the site where these images are rendered at 267x267, I found this out when downloading the Google PageSpeed optimized content. Google正在抓取以267x267呈现这些图像的网站,我在下载Google PageSpeed优化内容时发现了这一点。 But depending on viewport this image may need to be 500px x 500px. 但根据视口,此图像可能需要为500px x 500px。

How do I go about solving this problem? 我该如何解决这个问题? Ideally, I'd like to use mod_pagespeed to solve this problem, so I can reuse this solution across my servers. 理想情况下,我想使用mod_pagespeed解决此问题,因此我可以在服务器上重用此解决方案。 However, at this point, I'm open to about any solution that allows me to have this image vary in size via programming ie not creating an image for every size, unless this can be done dynamically without user involvement. 但是,在这一点上,我对允许通过编程使此图像的大小有所变化的任何解决方案都持开放态度,即不为每种尺寸创建图像,除非可以在没有用户参与的情况下动态地完成此操作。

Any help would be greatly appreciated. 任何帮助将不胜感激。 BTW, without these images I score a 96-98/100 顺便说一句,没有这些图像,我的得分是96-98 / 100

Site in Question Magento Responsive Site / Apache w/ mod_pagespeed 有问题的站点 Magento响应站点/ Apache,带mod_pagespeed

Google PageSpeed Results Link Google PageSpeed结果链接

图片引起问题

在此处输入图片说明

mod_pagespeed Settings mod_pagespeed设置

############################################
## mod_pagespeed

<IfModule pagespeed_module>
    ModPageSpeed on
    ModPagespeedDisallow "*index.php/admin/*"
    ModPagespeedCriticalImagesBeaconEnabled true
    ModPagespeedEnableFilters insert_image_dimensions
    ModPagespeedEnableFilters insert_dns_prefetch
    ModPagespeedEnableFilters pedantic
    ModPagespeedEnableFilters prioritize_critical_css
    ModPagespeedRewriteLevel CoreFilters
    ModPagespeedEnableFilters defer_javascript
    ModPagespeedEnableFilters sprite_images
    ModPagespeedEnableFilters rewrite_images
    ModPagespeedEnableFilters convert_png_to_jpeg,convert_jpeg_to_webp
    ModPagespeedEnableFilters resize_rendered_image_dimensions
    ModPagespeedEnableFilters collapse_whitespace,remove_comments
    ModPagespeedAddOptionsToUrls on
    #This caches scripts and images in your local storage, so to flush you cache, flush your local storage as well.
    ModPagespeedEnableFilters local_storage_cache
</IfModule>

Your problem may be caused by your images not being optimized properly. 您的问题可能是由于图像未正确优化引起的。

I have recently developed a BULK image optimizer for PHP websites that is 100% compliant with Google Insights´ guidelines. 我最近为PHP网站开发了BULK图像优化器,该图像优化器100%符合Google Insights的准则。

The only requirement is that you have imagick installed on your webserver. 唯一的要求是您在网络服务器上安装了imagick。

You can download the optimizer here: https://www.genius-webdesign.com/image-optimizer/ 您可以在此处下载优化器: https : //www.genius-webdesign.com/image-optimizer/

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

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