Fix top vault listing cache versioning - #1296
Merged
Merged
Conversation
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.
Why
A transient mismatch was reported where the vault listing showed a stale 1M annualised return for the Peter Schiff vault while the detail page showed the refreshed negative return. Production data later converged, which points to stale listing/cache data rather than a return formatter bug.
The risky paths were the separate compressed
/top-vaults/all-datapayload cache and the browser in-memory listing cache. Either could keep an older listing payload around after SSR layout/detail data had moved to a newer top-vault dataset.Lessons learnt
Use the dataset
generated_atvalue as an in-app payload freshness check, not as a query-string cache key. Cloudflare R2 may strip query parameters from the underlying export path, so URL timestamp cache busting is not a reliable correctness mechanism here.Avoid forcing HTTP revalidation on every listing request. Use a short HTTP freshness window and let the client do an explicit reload only when the returned payload timestamp is provably older than the SSR layout data.
Summary
/top-vaults/all-dataURLs stable; no timestamp or generated-at query parameters are added./top-vaults/all-datapayload cache bygenerated_at./top-vaults/all-datatoCache-Control: public, max-age=300, stale-while-revalidate=300to avoid checking the server on every listing request.generatedAtinto vault listing/chart client cache calls, then compare it against the payloadgenerated_attimestamp.fetch(..., { cache: 'reload' })if the returned payload is older than the layout dataset version.