From d410daca035d6a1675093a8ac57863f27d80dcc8 Mon Sep 17 00:00:00 2001 From: Kolsch Systems Date: Mon, 16 Aug 2021 13:09:35 -0700 Subject: [PATCH 1/3] Add 'webp' image format to list of cached files --- global/server/static-files.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/global/server/static-files.conf b/global/server/static-files.conf index da52a95..7cc3f12 100644 --- a/global/server/static-files.conf +++ b/global/server/static-files.conf @@ -9,7 +9,7 @@ location ~* \.(?:rss|atom)$ { } # Caches images, icons, video, audio, HTC, etc. -location ~* \.(?:jpg|jpeg|gif|png|ico|cur|gz|svg|mp4|ogg|ogv|webm|htc)$ { +location ~* \.(?:jpg|jpeg|gif|png|ico|cur|gz|svg|mp4|ogg|ogv|webm|htc|webp)$ { expires 1y; access_log off; } From 154784387abd7236d57ce6a39293a85d0d06fb12 Mon Sep 17 00:00:00 2001 From: Kolsch Systems Date: Mon, 16 Aug 2021 13:28:51 -0700 Subject: [PATCH 2/3] Check if web browser supports WebP images --- global/http.conf | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/global/http.conf b/global/http.conf index faf1e6d..fc7d426 100644 --- a/global/http.conf +++ b/global/http.conf @@ -5,4 +5,10 @@ sendfile on; tcp_nopush on; # Don't wait to send data in keep-alive state. -tcp_nodelay on; \ No newline at end of file +tcp_nodelay on; + +# Check if web browser supports WebP images +map $http_accept $webp_suffix { + default ""; + "~*webp" ".webp"; +} \ No newline at end of file From 8e62c19fcac0df364721ecbd1649dd485f96debe Mon Sep 17 00:00:00 2001 From: Kolsch Systems Date: Mon, 16 Aug 2021 14:13:37 -0700 Subject: [PATCH 3/3] Use the WebP version of converted PNG/JPEG images --- global/server/static-files.conf | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/global/server/static-files.conf b/global/server/static-files.conf index 7cc3f12..e4aba67 100644 --- a/global/server/static-files.conf +++ b/global/server/static-files.conf @@ -8,6 +8,12 @@ location ~* \.(?:rss|atom)$ { expires 1h; } +# Use the WebP version of converted PNG/JPEG images +location ~* ^.+\.(png|jpe?g)$ { + add_header Vary Accept; + try_files $uri$webp_suffix $uri =404; +} + # Caches images, icons, video, audio, HTC, etc. location ~* \.(?:jpg|jpeg|gif|png|ico|cur|gz|svg|mp4|ogg|ogv|webm|htc|webp)$ { expires 1y;