Fix SVG export returning stale content after tool edits#108
Merged
Conversation
Browser cached the SVG download because the URL never changed between edits. Add cache-busting query parameter tied to save count so each successful save produces a distinct download URL. Also set Cache-Control: no-cache on the backend SVG response as defence in depth. Signed-off-by: Jason Madigan <[email protected]>
Backend: test Cache-Control no-cache header on SVG download endpoint, valid SVG content, and 404 for missing tools. Frontend: test useDebouncedSave saveCount starts at 0, increments after save, and saving state tracks in-progress saves. Adds @testing-library/react and jsdom as dev dependencies for hook testing. Signed-off-by: Jason Madigan <[email protected]>
jasonmadigan
marked this pull request as ready for review
June 24, 2026 16:20
shanetinklenberg
pushed a commit
to shanetinklenberg/tracefinity
that referenced
this pull request
Jun 28, 2026
) * Fix SVG export returning stale content after tool edits (tracefinity#97) Browser cached the SVG download because the URL never changed between edits. Add cache-busting query parameter tied to save count so each successful save produces a distinct download URL. Also set Cache-Control: no-cache on the backend SVG response as defence in depth. Signed-off-by: Jason Madigan <[email protected]> * Add tests for SVG export caching fix (tracefinity#97) Backend: test Cache-Control no-cache header on SVG download endpoint, valid SVG content, and 404 for missing tools. Frontend: test useDebouncedSave saveCount starts at 0, increments after save, and saving state tracks in-progress saves. Adds @testing-library/react and jsdom as dev dependencies for hook testing. Signed-off-by: Jason Madigan <[email protected]> --------- Signed-off-by: Jason Madigan <[email protected]>
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.
Summary
Fixes a bug where downloading the SVG from the tool editor always returned the initial version, ignoring edits made by the user. The browser cached the static SVG URL and served stale content on subsequent downloads.
Closes #97
Changes
useDebouncedSave.ts-- addedsaveCountstate that increments on each successful savetools/[id]/page.tsx-- appends?v={saveCount}to SVG download URL, busting browser cache after editsroutes.py-- addedCache-Control: no-cacheheader on the SVG endpoint as defence-in-depthTests
test_svg_cache_header.py-- verifies Cache-Control header, valid SVG content, and 404 for missing tooluseDebouncedSave.test.ts-- verifies saveCount starts at 0, increments after save, and saving state tracks correctly