From 23aa893d010e7edd9ff5d21807d4cf598db5bfaa Mon Sep 17 00:00:00 2001 From: Robbie1977 Date: Sun, 30 Aug 2026 00:11:35 +0000 Subject: [PATCH] Never cache the interactive API docs (/ and /docs.json) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit vfbquery >= 1.22.42 serves interactive API documentation at its root and a machine-readable catalogue at /docs.json, both generated in-memory from the *running* package version. Cached under CACHE_STALE_TIME they would keep naming — and documenting — a release that is no longer deployed, for up to a month after every upgrade. A request-uri map marks the two paths and feeds proxy_cache_bypass and proxy_no_cache, so every other path keeps the existing cache behaviour. Verified against a live vfbquery upstream: / and /docs.json answer BYPASS on every request while /get_term_info still goes MISS then HIT, and the rendered config passes nginx -t. --- nginx.conf.template | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/nginx.conf.template b/nginx.conf.template index e269573..4f68c5e 100644 --- a/nginx.conf.template +++ b/nginx.conf.template @@ -64,6 +64,17 @@ http { include /etc/nginx/blocked-ips*.map; } + # The interactive API documentation (/ and /docs.json, served by + # vfbquery >= 1.22.42) is generated in-memory by the upstream from its + # *running* version, so it must never be cached: a cached copy would + # keep naming — and documenting — a vfbquery release that is no longer + # deployed, for up to CACHE_STALE_TIME after every upgrade. Both + # responses are tiny and cost the upstream nothing to serve fresh. + map $request_uri $is_api_docs { + default 0; + ~^/(?:docs\.json)?(?:\?.*)?$ 1; + } + # Whitelist wins over blocklist and probe detection. map "$is_whitelisted_ip:$is_blocked_ip" $should_block_ip { default 0; @@ -186,7 +197,8 @@ http { add_header X-Cache-Status $upstream_cache_status; add_header X-Cache-Key "$request_method$request_uri"; proxy_ignore_headers Cache-Control Expires Set-Cookie; - proxy_cache_bypass $force_refresh; + proxy_cache_bypass $force_refresh $is_api_docs; + proxy_no_cache $is_api_docs; proxy_cache owlery_cache; } } @@ -250,7 +262,8 @@ http { add_header X-Cache-Status $upstream_cache_status; add_header X-Cache-Key "$request_method$request_uri"; proxy_ignore_headers Cache-Control Expires Set-Cookie; - proxy_cache_bypass $force_refresh; + proxy_cache_bypass $force_refresh $is_api_docs; + proxy_no_cache $is_api_docs; proxy_cache owlery_cache; } }