From c82e234d6c522fcc6e08a61a5b4e39b0d498a94f Mon Sep 17 00:00:00 2001 From: AI Assistant Date: Fri, 27 Mar 2026 22:47:39 +0200 Subject: [PATCH] perf(tile-cache): fix compression passthrough + 7d TTL + browser caching MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Remove Accept-Encoding stripping — Martin gzip passes through to client (was sending uncompressed tiles, wasting bandwidth and cache space) - Increase cache TTL from 1h to 7d (tiles change only on weekly sync) - Increase inactive eviction from 24h to 7d - Add Cache-Control header for browser caching (24h + stale-while-revalidate 7d) - 204 (empty tiles) cached 1h instead of 1m (they don't change either) Co-Authored-By: Claude Opus 4.6 (1M context) --- nginx/tile-cache.conf | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/nginx/tile-cache.conf b/nginx/tile-cache.conf index 5623c61..8cbaf30 100644 --- a/nginx/tile-cache.conf +++ b/nginx/tile-cache.conf @@ -5,7 +5,7 @@ proxy_cache_path /var/cache/nginx/tiles levels=1:2 keys_zone=tiles:64m max_size=2g - inactive=24h + inactive=7d use_temp_path=off; server { @@ -31,16 +31,19 @@ server { proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; - # Cache config + # Cache config — tiles change only on sync (weekly), long TTL is safe proxy_cache tiles; proxy_cache_key "$request_uri"; - proxy_cache_valid 200 1h; - proxy_cache_valid 204 1m; + proxy_cache_valid 200 7d; + proxy_cache_valid 204 1h; proxy_cache_valid 404 1m; proxy_cache_use_stale error timeout updating http_500 http_502 http_503 http_504; proxy_cache_lock on; proxy_cache_lock_timeout 5s; + # Browser caching — tiles are immutable between syncs + add_header Cache-Control "public, max-age=86400, stale-while-revalidate=604800" always; + # Pass cache status header (useful for debugging) add_header X-Cache-Status $upstream_cache_status always; @@ -59,8 +62,7 @@ server { return 204; } - # Martin already compresses — pass through - proxy_set_header Accept-Encoding ""; + # Let Martin gzip natively — pass compressed response through to client and cache gzip off; # Timeouts (Martin can be slow on low-zoom tiles)