Skip to content

Fix SVG export returning stale content after tool edits#108

Merged
jasonmadigan merged 2 commits into
mainfrom
97-fix-svg-export-caching
Jun 24, 2026
Merged

Fix SVG export returning stale content after tool edits#108
jasonmadigan merged 2 commits into
mainfrom
97-fix-svg-export-caching

Conversation

@jasonmadigan

Copy link
Copy Markdown
Collaborator

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 -- added saveCount state that increments on each successful save
  • tools/[id]/page.tsx -- appends ?v={saveCount} to SVG download URL, busting browser cache after edits
  • routes.py -- added Cache-Control: no-cache header on the SVG endpoint as defence-in-depth

Tests

  • Backend: added test_svg_cache_header.py -- verifies Cache-Control header, valid SVG content, and 404 for missing tool
  • Frontend: added useDebouncedSave.test.ts -- verifies saveCount starts at 0, increments after save, and saving state tracks correctly
  • All existing tests pass (165 backend, 78 frontend)

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
jasonmadigan marked this pull request as ready for review June 24, 2026 16:20
@jasonmadigan
jasonmadigan merged commit 33459fd into main Jun 24, 2026
1 check passed
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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SVG export in tool editor always gives initial svg

1 participant