apache / incubator-pagespeed-ngx

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

Jpeg file name does not become suffixed with webp when using convert_jpeg_to_webp #1501

Open zibuyule opened 6 years ago

zibuyule commented 6 years ago

Hi,

Please visit the link website.

I can see that its type is webp, but its file name does not become suffixed with webp.

Noted: Before testing, you should add a line to the hosts file: 54.193.8.81 res.ebdcdn.com

I pointed my computer's host file to my original address. This can ignore the impact of aws cloudfront.

This is very strange. Can you help me?

webp

webp2

nginx version: nginx/1.9.4 ngx_pagespeed version: ngx_pagespeed-1.12.34.3-stable

Posted my configuration is as follows:

root@web-ebd:/usr/local/nginx/conf/conf.d# cat pagespeed/ebdcdn.pagespeed.conf                
pagespeed on;

## Needs to exist and be writable by nginx.  Use tmpfs for best performance.
pagespeed FileCachePath /var/ngx_pagespeed_cache;
pagespeed FileCacheCleanIntervalMs 43200000;
pagespeed FileCacheSizeKb 2048000;
pagespeed FileCacheInodeLimit 500000;

## Ensure requests for pagespeed optimized resources go to the pagespeed handler
## and no extraneous headers get set.
location ~ "\.pagespeed\.([a-z]\.)?[a-z]{2}\.[^.]{10}\.[^.]+" { add_header "" ""; }
location ~ "^/pagespeed_static/" { }
location ~ "^/ngx_pagespeed_beacon$" { }

if ($request_uri ~ "(ngx_pagespeed_([^.]+)/(.*)?)") { break; }

pagespeed Domain https://www.eyebuydirect.com;
pagespeed Domain https://res.ebdcdn.com;

pagespeed AddResourceHeader "Access-Control-Allow-Origin" "https://res.ebdcdn.com";
pagespeed AddResourceHeader "Access-Control-Allow-Origin" "https://www.eyebuydirect.com";

pagespeed PreserveUrlRelativity on;

## Optimize images
pagespeed EnableFilters rewrite_images;
pagespeed RewriteLevel PassThrough;
pagespeed RewriteLevel OptimizeForBandwidth;

pagespeed EnableFilters convert_png_to_jpeg;
pagespeed EnableFilters convert_jpeg_to_webp;
#pagespeed EnableFilters convert_to_webp_lossless;

Thanks

oschaaf commented 6 years ago

Why do you want the webp suffix to show in the file name?

Lofesa commented 6 years ago

Hi @zibuyule I tested the site and seems that cloudfront has stored unoptimized resources and serves it rater that the pagespeed optimized. The files are viewed as jpg and png not webp. In other hand, the clodfront fire intermitent 404 errors as you can see in these header: Age:140 Cache-Control:max-age=0, no-cache Connection:keep-alive Content-Encoding:gzip Content-Type:text/html; charset=utf-8 Date:Wed, 15 Nov 2017 06:47:46 GMT ETag:"52935bc6-0" Server:nginx Transfer-Encoding:chunked Via:1.1 51883933352ded6e633a13496905cdde.cloudfront.net (CloudFront) X-Amz-Cf-Id:L8P6QK5-6AI36V5jcM1SbEdC-uX2n5fm7_JMOyhUhzujmFgI3GZw== X-Cache:Error from cloudfront X-Page-Speed:1.12.34.3-0

Googling I found this

@oschaaf when using chrome the files can be converted to webp.

zibuyule commented 6 years ago

@lofesa Before testing, you should add a line to the hosts file: 54.193.8.** res.ebdcdn.com

This can ignore the impact of aws cloudfront.

Lofesa commented 6 years ago

I done this, and some other CDN other than Cloudfront is involved Request URL:https://www.eyebuydirect.com/telist/image-eyeglasses.html content-encoding:gzip content-type:text/html; charset=utf-8 date:Wed, 15 Nov 2017 07:28:14 GMT etag:W/"5a0978b2-2b3b8" last-modified:Mon, 13 Nov 2017 10:49:22 GMT server:nginx status:200 vary:User-Agent x-cdn:Incapsula x-iinfo:9-54065145-54064178 PNNN RT(1510730894135 0) q(0 0 0 -1) r(7 7) U10000

and yes, some files are jpg but in type show as webp

Request URL:http://res.ebdcdn.com/upload/banner/201711/social/index-social-9.**jpg Accept-Ranges:bytes Cache-Control:max-age=315275163 Connection:keep-alive Content-Length:3916 Content-Type:image/webp Date:Wed, 15 Nov 2017 07:32:42 GMT ETag:W/"PSA-aj-Nb7-37d3cT" Expires:Fri, 12 Nov 2027 07:58:46 GMT Server:nginx Vary:User-Agent,Save-Data X-Cache:HIT** X-Original-Content-Length:7463

zibuyule commented 6 years ago

@Lofesa Sorry! Before testing, you should add two lines to the hosts file: 54.193.8. res.ebdcdn.com 54.193.5. www.eyebuydirect.com

Lofesa commented 6 years ago

@zibuyule With these changes I am getting a missed results. Files that seems don´t be "pagespeezed" and files that yes. For example: This file seems that is not served by pagespeed: Request URL:https://res.ebdcdn.com/upload/banner/201708/progressive-sunglasses.032008147296.jpg Request Method:GET Status Code:200 OK Remote Address:54.193.8.81:443 Referrer Policy:no-referrer-when-downgrade Response Headers view source Accept-Ranges:bytes Cache-Control:max-age=315360000 Connection:keep-alive Content-Length:8026 Content-Type:image/jpeg Date:Wed, 15 Nov 2017 08:04:28 GMT ETag:"5a0bdda1-1f5a" Expires:Thu, 31 Dec 2037 23:55:55 GMT Last-Modified:Wed, 15 Nov 2017 06:24:33 GMT Server:nginx X-Cache:HIT

As you see this file content-type jpeg and file extension jpg are the rigth. I see that Etag is not rewrited by pagespeed and had X-cache:HIT that make me suspect the file is served by a cdn or other cahe system.

This other file: Request URL:http://res.ebdcdn.com/upload/banner/201711/social/index-social-9.jpg Request Method:GET Status Code:200 OK Remote Address:54.193.8.81:80 Referrer Policy:no-referrer-when-downgrade Response Headers view source Accept-Ranges:bytes Cache-Control:max-age=315273257 Connection:keep-alive Content-Length:3916 Content-Type:image/webp Date:Wed, 15 Nov 2017 08:04:28 GMT ETag:W/"PSA-aj-Nb7-37d3cT" Expires:Fri, 12 Nov 2027 07:58:46 GMT Server:nginx Vary:User-Agent,Save-Data X-Cache:HIT X-Original-Content-Length:7463

Had a mismacht from the conten type and the file extension. The ETag is rewrited by pagespeed, as far as the W/PSA become from pagespeed, but have a X-Cache:HIT .

None of these files had the x-page-speed: header. I suspect that files are served from a cdn or cache system that stores the original file.

In other hand, in the config you have 2 statements that are incompatible:

pagespeed RewriteLevel PassThrough; pagespeed RewriteLevel OptimizeForBandwidth;

Only 1 of these must be set.

And you have these: pagespeed Domain https://www.eyebuydirect.com; pagespeed Domain https://res.ebdcdn.com;

These directives are supossed to only auth the https url, but you have a mixed https and http. Try to use

pagespeed Domain http*://*.eyebuydirect.com;
pagespeed Domain http*://*.ebdcdn.com;

this cover all the subdomains and the http/https.

Is possible to totaly disable cdn/cache system to test if pagespeed is working?