Answer the question
In order to leave comments, you need to log in
How to change nginx image?
There are two pictures on the site.
/images/image.jpg
/images/image.webp
/images/image.jpg
returned /images/image.webp
on the condition that in request header
Accept:image/webp
i.e. browser supports webp format. /images/image.jpg
it in such a browser, I will see in the response headers Content-Type:image/webp
, and Content-Length
it will correspond to/images/image.webp
Answer the question
In order to leave comments, you need to log in
something like this:
if ($http_accept ~* "image/webp") {
rewrite ^/(.*)\.jpg$ /$1.webp;
}
Convenient conversion and substitution for the desired format is in the pagespeed module from Google.
https://github.com/pagespeed/ngx_pagespeed
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question