Nginx next try explicit replacement
This commit is contained in:
@ -1,14 +1,21 @@
|
||||
map $http_accept $webp_suffix {
|
||||
default "";
|
||||
"~*webp" ".webp";
|
||||
}
|
||||
|
||||
server {
|
||||
listen 80;
|
||||
listen [::]:80;
|
||||
server_name localhost;
|
||||
|
||||
location ~* ^/.+\.(jpg|jpeg|png|gif)$ {
|
||||
# Check if client is capable of handling webp
|
||||
map $http_accept $webp_suffix {
|
||||
default "";
|
||||
"~*webp" ".webp";
|
||||
}
|
||||
|
||||
# Capture image path, without the file extension
|
||||
map $uri $image {
|
||||
~*^/(images)/(.+)\.(jpe?g|png)$ /$1/$2;
|
||||
}
|
||||
|
||||
location ~* ^/.+\.(jpg|jpeg|png)$ {
|
||||
root /usr/share/nginx/html;
|
||||
# BEGIN Browser Caching of WebP
|
||||
expires 180d;
|
||||
@ -17,7 +24,7 @@ server {
|
||||
# END Browser Caching of WebP
|
||||
|
||||
add_header Vary Accept;
|
||||
try_files $uri$webp_suffix $uri =404;
|
||||
try_files $image$webp_suffix $uri =404;
|
||||
}
|
||||
|
||||
location / {
|
||||
|
Reference in New Issue
Block a user