apache / incubator-pagespeed-mod

Apache module for rewriting web pages to reduce latency and bandwidth.
http://modpagespeed.com
Apache License 2.0
693 stars 157 forks source link

Images don't get converted to webp in ajax requests #2085

Open datamints-off opened 3 years ago

datamints-off commented 3 years ago

We're using a banner system to load ads via ajax. The images in the ajax responses are handled by mod_pagespeed, but they're not converted to webp. If I call the ajax url directly in the browser, the image is delivered as webp. Is this some kind of bug or do we have to adjust our configuration?

Example: Visit https://www.whisky.de/forum/ and check the banner on top, then call https://www.whisky.de/?type=9001&tx_sfbanners_pi1%5Baction%5D=getBanners&tx_sfbanners_pi1%5Bcontroller%5D=Banner&tx_sfbanners_pi1%5BcurrentPageUid%5D=1&tx_sfbanners_pi1%5Bhmac%5D=5c7c784ee0e0f4c801dfbb52b15426ceed38550f&tx_sfbanners_pi1%5BstartingPoint%5D=&tx_sfbanners_pi1%5Bcategories%5D=579&tx_sfbanners_pi1%5BdisplayMode%5D=random&cHash=012f2fb0e52bdaaee69016443b9e3f21

Lofesa commented 3 years ago

Hi Not only the banner, seems is in all images that are precessed by pagespeed, like:

https://www.whisky.de/shop/out/pictures/generated/product1/380_280_75ximage_AUCHE0SA0_1.jpg.pagespeed.ic.IGu2yp7Fut.jpg

All these images get processed by pagespeed but not converted to web. And seems all are downloaded by javascript so at a start they don´t are pagespeed processed unless by IPRO, but IPRO don´t chage the url. Also seems that https://www.whisky.de/ is running pagespeed but https://www.whisky.de/forum/ not.

What´s the config for this site?

jmarantz commented 3 years ago

I am assuming you checked the content-type of the ajax-loaded images in the chrome dev tools?

On Fri, Oct 29, 2021 at 4:29 AM Lofesa @.***> wrote:

Hi Not only the banner, seems is in all images that are precessed by pagespeed, like:

https://www.whisky.de/shop/out/pictures/generated/product1/380_280_75ximage_AUCHE0SA0_1.jpg.pagespeed.ic.IGu2yp7Fut.jpg

All these images get processed by pagespeed but not converted to web. And seems all are downloaded by javascript so at a start they don´t are pagespeed processed unless by IPRO, but IPRO don´t chage the url. Also seems that https://www.whisky.de/ is running pagespeed but https://www.whisky.de/forum/ not.

What´s the config for this site?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/apache/incubator-pagespeed-mod/issues/2085#issuecomment-954552905, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAO2IPMDXZW36DWS276TPADUJJSRDANCNFSM5G6U7EIA .

datamints-off commented 3 years ago

@jmarantz Yes, I checked the content type: the browser accepts image/webp,image/apng,image/svg+xml,image/*, the server returns image/jpeg.

datamints-off commented 3 years ago

@Lofesa The site consists of three systems behind a Nginx reverse proxy. mod_pagespeed is not enabled for the one at /forum, but for the one at / (you can see this when checking the images at https://www.whisky.de).

datamints-off commented 3 years ago

This is the configuration for mod_pagespeed:

<IfModule pagespeed_module>
    ModPagespeed on
    AddOutputFilterByType MOD_PAGESPEED_OUTPUT_FILTER text/html
    ModPagespeedDomain *.whisky.de
    ModPagespeedDomain https://*.whisky.de
    ModPagespeedDisallow */typo3/*
    ModPagespeedDisallow */tiny_fck/*
    ModPagespeedDisallow */modules/wysiwyg/*
    ModPagespeedDisallow */ckeditor/*
    ModPagespeedRespectXForwardedProto on
    ModPagespeedUrlValuedAttribute a data-zoom-image image
    ModPagespeedUrlValuedAttribute a data-image image
    ModPagespeedRewriteLevel PassThrough
    ModPagespeedEnableFilters rewrite_images
    ModPagespeedLazyloadImagesAfterOnload off
</IfModule>
jmarantz commented 3 years ago

One other subtlety around this: there are few caches in the path, potentially that may need to be warmed by retrying a few times.

usually shift-refresh in the browser a few times gets you the fully optimized versions.

Lofesa commented 3 years ago

Hi Even in https://www.whisky.de/ banner images are not webp converted but images in the html code get it. Son I´m still thinking is how javascript request the image or how it creates the dom node

datamints-off commented 3 years ago

Thanks for all your input: I found that the accept header of the request fetching the banner is not stating that webp images are accepted. I will change that on the client and the problem should be solved.