From 96d656ca504852e91dc9fd9985d29442c5d8a173 Mon Sep 17 00:00:00 2001 From: Grant Slater Date: Wed, 24 Jun 2026 23:42:30 +0100 Subject: [PATCH] imagery: additional performance tweaks --- cookbooks/imagery/recipes/za_ngi_aerial.rb | 4 ++-- .../default/nginx_imagery_layer_fragment.conf.erb | 12 ++++++++---- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/cookbooks/imagery/recipes/za_ngi_aerial.rb b/cookbooks/imagery/recipes/za_ngi_aerial.rb index 2231b48db..e8b0781c9 100644 --- a/cookbooks/imagery/recipes/za_ngi_aerial.rb +++ b/cookbooks/imagery/recipes/za_ngi_aerial.rb @@ -33,8 +33,8 @@ imagery_layer "ngi-aerial" do source "sqlite:///store/imagery/za/za-25cm/mosaic-tiler-file.db.sqlite:mosaic" copyright 'State Copyright © 2024 Chief Directorate: National Geo-spatial Information' max_zoom 20 - extension "jpg" + extension "png" default_layer true url_aliases ["/ngi-aerial"] - revision 3 + revision 4 end diff --git a/cookbooks/imagery/templates/default/nginx_imagery_layer_fragment.conf.erb b/cookbooks/imagery/templates/default/nginx_imagery_layer_fragment.conf.erb index cd404771a..1a67b0995 100644 --- a/cookbooks/imagery/templates/default/nginx_imagery_layer_fragment.conf.erb +++ b/cookbooks/imagery/templates/default/nginx_imagery_layer_fragment.conf.erb @@ -8,7 +8,7 @@ location ~* "^/layer/<%= @layer %>/(\d+)/(\d+)/(\d+)\.(jpg|jpeg|png|webp)$" { set $ext $4; # Serve local file if present; otherwise jump to proxy - try_files /layer/<%= @layer %>/$z/$x/$y.jpg /layer/<%= @layer %>/$z/$x/$y.jpeg /layer/<%= @layer %>/$z/$x/$y.png /layer/<%= @layer %>/$z/$x/$y.webp @<%= @site %>_<%= @layer %>_backend; + try_files /layer/<%= @layer %>/layer/<%= @layer %>/$z/$x/$y.$ext /layer/<%= @layer %>/$z/$x/$y.png @<%= @site %>_<%= @layer %>_backend; gzip off; expires off; @@ -53,7 +53,7 @@ location @<%= @site %>_<%= @layer %>_backend { proxy_cache_background_update on; proxy_next_upstream error timeout invalid_header; - proxy_next_upstream_tries 1; + proxy_next_upstream_tries 2; proxy_intercept_errors on; proxy_ignore_headers "Cache-Control"; @@ -81,8 +81,12 @@ location @<%= @site %>_<%= @layer %>_backend { fastcgi_cache_valid 200 21d; + fastcgi_cache_lock on; + fastcgi_cache_lock_timeout 180s; + fastcgi_cache_lock_age 180s; + # Serve stale cache on errors or if updating - fastcgi_cache_use_stale error timeout updating http_500 http_503; + fastcgi_cache_use_stale error timeout updating http_500 http_503 http_504; # If in cache as stale, serve stale and update in background fastcgi_cache_background_update on; # Enable revalidation using If-Modified-Since and If-None-Match for stale items @@ -92,7 +96,7 @@ location @<%= @site %>_<%= @layer %>_backend { fastcgi_catch_stderr "Image handling error"; - fastcgi_next_upstream error timeout invalid_header http_500 http_503; + fastcgi_next_upstream error timeout invalid_header http_500 http_503 http_504; fastcgi_next_upstream_tries 8; <% end -%> gzip off; -- 2.47.3