apache / incubator-pagespeed-ngx

Automatic PageSpeed optimization module for Nginx
http://ngxpagespeed.com/
Apache License 2.0
4.36k stars 363 forks source link

convert_jpeg_to_webp not working!? #1614

Open ZTzha opened 5 years ago

ZTzha commented 5 years ago

/img/1.jpg ->working
chrome get ->img/x1.jpg.pagespeed.ic.oi_Bc-Td8w.webp 1.jpg original-size:59.27KB 800x500 1.jpg.webp size: 9.7KB 800x500

that's great, but:

/img/4.jpg -> not working chrome get ->img/4.jpg 4.jpg original-size:4.19MB 7952x5304

no error.log

second problems: html-code--> img src="http://x.x.x.x/img/test.jpg" x.x.x.x is not my server. jpeg_to_webp not working... chrome still get original image,and show Request Headers "Provisional headers are shown" /var/cache/ngx_pagespeed does not get test.jpg,

my nginx.conf ----->

server { listen 1159;

location / {

root html;
index  index.html index.htm;

pagespeed EnableFilters recompress_images;
    pagespeed EnableFilters convert_gif_to_png;
    pagespeed EnableFilters convert_jpeg_to_webp;
    pagespeed EnableFilters recompress_webp;
    pagespeed ImageRecompressionQuality 10;

}

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

}

nginx-version: 1.15.8 ngx_pagespeed-version: 1.13.35.2-stable operation-system: centos 7

oschaaf commented 5 years ago

If you enable the debug filter, html comments will be written right after the img tags that may shed some light on what happens and why.

ZTzha commented 5 years ago

first problem image debug: The image was not inlined because you have chosen to only inline the critical images but this image is not critical.

second problem image debug: The preceding resource was not rewritten because its domain (x.x.x.x) is not authorized

how can i solve it @oschaaf

Lofesa commented 5 years ago

Hi @ZTzha The message say that you enabed the inline_images but not configured the pagespeed pagespeed ImageInlineMaxBytes MaxBytes; so the default size is 2048 bytes and the image is greater than that. If you don´t see these image optimized can be because it need some it to optimze resources. Some image filters need that pagespeed CriticalImagesBeaconEnabled true; be enabled to work. The second issue is not solvable unless in that domain pagespeed module is working. If you authorize these domain (pagespeed Domain http://x.x.x.x;) then pagespeed request a rewrited resource and the original server say 404 resource not found because it don understand rewrited url.

ZTzha commented 5 years ago

Hi @Lofesa As you advice,I add the config “pagespeed CriticalImagesBeaconEnabled true;” and “pagespeed ImageInlineMaxBytes 102400000000;”,and close passthrough, then reload my nginx. refresh my test-website 3 times, /img/4.jpg change to img/4.jpg.pagespeed.ce.k_vyVMeiuE.jpg but the image size still 4.2MB and jpg not convert to webp and show debug The image was not inlined because it has too many bytes. I think i set the MaxBytes is enough

Lofesa commented 5 years ago

/img/4.jpg change to img/4.jpg.pagespeed.ce.k_vyVMeiuE.jpg The xx.ce.xx is cache extend, this image only had applied the cache extender filter. Well... the image is 7952x5304 = 42.177.408 Try to use pagespeed ImageResolutionLimitBytes 45.000.000, by default these value is 32.000.000 And the max size an object can use in cache is determined by pagespeed MaxCacheableContentLength 16777216; So you can use the -1 value to this param to have no limit in the size of objects stored in pagespeed cache.

ZTzha commented 5 years ago

@Lofesa thank you very much!it is great solution for my problem