Never cache the interactive API docs (/ and /docs.json) - #10
Closed
Robbie1977 wants to merge 1 commit into
Closed
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
vfbquery ≥ 1.22.42 (VirtualFlyBrain/VFBquery#96) serves interactive API documentation at its root and a machine-readable catalogue at
/docs.json, both generated in-memory from the running package version. Behind this cache they would be stored underCACHE_STALE_TIME, so after every vfbquery upgrade the docs would keep naming — and documenting — the previous release for up to a month.A
$request_urimap marks the two paths and feedsproxy_cache_bypass+proxy_no_cache, so they are always fetched fresh while every other path keeps the existing cache behaviour. Both responses are tiny and computed in-memory upstream, so the bypass costs nothing.Why
Without it, the docs page at https://v3-cached.virtualflybrain.org/ would go stale on the first upgrade after it appears.
How to test
Rendered the template through the entrypoint's own
envsubstset and rannginx -t(clean), then ran the config in front of a live vfbquery:/and/docs.jsonanswerX-Cache-Status: BYPASSon every request,/get_term_infostill goesMISSthenHIT.test/ip-maps-test.shpasses;test/cache-sync-test.shfails identically on the base branch in this environment (rsync/find variance), untouched by this change.Follow-ups left
None in this repo — the page appears once the vfbquery release is deployed as the upstream.