Pagespeed未优化网站图片的一部分

时间:2019-07-14 14:05:20

标签: nginx pagespeed mod-pagespeed

我有nginx 1.16pagespeed 1.13.35.2-0。问题是pagepseed能够优化主页而不是其他页面的图像。没有错误或可疑的日志。

媒体/目录/产品/缓存下存在任何图像的位置不会得到优化。

Pagespeed配置文件:

#pagespeed config 

pagespeed ForceCaching on;
pagespeed RewriteLevel CoreFilters;
pagespeed RespectXForwardedProto on;
pagespeed RateLimitBackgroundFetches off;
pagespeed MaxCacheableContentLength -1;

pagespeed LoadFromFile "https://example.com/media/" "/home/example/www/media/";
pagespeed LoadFromFile "https://example.com/js/" "/home/example/www/js/";
pagespeed LoadFromFile "https://example.com/skin/" "/home/example/www/skin/";

pagespeed EnableFilters responsive_images;
pagespeed EnableFilters combine_heads;
pagespeed EnableFilters outline_css;
pagespeed EnableFilters outline_javascript;
pagespeed EnableFilters move_css_above_scripts;
pagespeed EnableFilters rewrite_style_attributes;
pagespeed EnableFilters prioritize_critical_css;
pagespeed EnableFilters make_google_analytics_async;
pagespeed EnableFilters inline_google_font_css;
pagespeed EnableFilters local_storage_cache;
pagespeed EnableFilters convert_to_webp_animated;
pagespeed EnableFilters insert_image_dimensions;
pagespeed EnableFilters inline_preview_images;
pagespeed EnableFilters resize_mobile_images;
pagespeed EnableFilters collapse_whitespace;
pagespeed EnableFilters elide_attributes;
pagespeed EnableFilters sprite_images;
pagespeed EnableFilters lazyload_images;
pagespeed EnableFilters extend_cache;

服务器配置:

include /etc/nginx/pagespeed.conf;

location ~ "\.pagespeed\.([a-z]\.)?[a-z]{2}\.[^.]{10}\.[^.]+" { add_header "" ""; }
location ~ "^/ngx_pagespeed_static/" { }
location ~ "^/ngx_pagespeed_beacon" { }


location ~* ^/media/catalog/product/cache/./.*/([\d]+)x/(.+)/(.+)/(.+)/(.+)$ {
        alias /home/example/www/media/catalog/product/$3/$4/$5;
        image_filter on;
        proxy_ignore_headers Cache-Control; 
        image_filter resize $1 $1;
        image_filter_buffer 200M;
        image_filter_interlace on;
        image_filter_jpeg_quality 98;
        error_page 415 = /empty;
        error_page 404   @missing_product_image;
}

location ~* ^/media/catalog/product/cache/./.*/([\d]+)x([\d]+)/(.+)/(.+)/(.+)/(.+)$ {
        alias /home/example/www/media/catalog/product/$4/$5/$6;
        image_filter on;
        proxy_ignore_headers Cache-Control;
        image_filter resize $1 $2;
        image_filter_buffer 200M;
        image_filter_interlace on;
        image_filter_jpeg_quality 98;
        error_page 415 = /empty;
        error_page 404   @missing_product_image;
        }

location ~* ^/media/catalog/product/cache/./image/.+/(.+)/(.+)/(.+)$ {
        alias /home/example/www/media/catalog/product/$1/$2/$3;
}


location ~* ^/skin/frontend/example/default/images/([\d]+)x([\d]+)/(.+)$ {
        alias /home/example/www/skin/frontend/example/default/images/$3;
        image_filter on;
        proxy_ignore_headers Cache-Control;
        image_filter resize $1 $2;
        image_filter_buffer 200M;
        image_filter_interlace on;
        image_filter_jpeg_quality 90;
        error_page 415 = /empty;
}

location @missing_product_image {
    rewrite /media/catalog/product/cache/./.*/([\d]+)x([\d]+)/(.+)/(.+)/(.+)/(.+) /skin/frontend/example/default/images/$1x$2/product_spacer.jpg redirect;
}

请注意,pagepseed正在nginx上使用图像过滤器来优化同一路径中的图像。但是,将其关闭并不能解决问题。

有什么建议吗?

0 个答案:

没有答案