Skip to content

Add content hashes to asset URLs#6749

Open
harsh21234i wants to merge 6 commits into
reflex-dev:mainfrom
harsh21234i:fix/asset-content-hash-6550
Open

Add content hashes to asset URLs#6749
harsh21234i wants to merge 6 commits into
reflex-dev:mainfrom
harsh21234i:fix/asset-content-hash-6550

Conversation

@harsh21234i

Copy link
Copy Markdown
Contributor

Closes #6550.

Adds content-hash cache busting to rx.asset URLs by appending an 8-character SHA-256 query parameter based on the
asset file contents.

Example:
rx.asset("logo.svg") now returns /logo.svg?v=<hash>.

The hash changes only when the file content changes, allowing browsers to cache assets safely across deploys.

Implementation notes:

  • Applies to both local and shared assets.
  • Keeps AssetPathStr.importable_path unversioned so existing build-time import behavior is preserved.
  • Preserves backend-only behavior for missing local assets.
  • Adds regression coverage for hash changes and pickle/copy round trips.

@harsh21234i harsh21234i requested review from a team and Alek99 as code owners July 11, 2026 06:15
@greptile-apps

greptile-apps Bot commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR adds content-hash cache busting to asset URLs. The main changes are:

  • Appends an eight-character SHA-256 value to local and shared asset URLs.
  • Preserves unversioned paths for build-time imports and serialization.
  • Reads files in chunks and retries when content changes during hashing.
  • Documents the new URL format and adds unit coverage.

Confidence Score: 5/5

No new blocking issue was identified in this follow-up.

  • The updated hashing code retries when consecutive reads differ.
  • Tests cover content changes, replacement, in-place rewrites, fallback behavior, and serialization.
  • No separate production failure requiring an additional comment was found.

Important Files Changed

Filename Overview
reflex/assets.py Adds versioned asset paths, chunked hashing, stability retries, and serialization support.
tests/units/assets/test_assets.py Adds coverage for hash changes, retry behavior, fallback behavior, and serialization.
docs/assets/overview.md Documents content-hash query parameters for asset URLs.
news/6550.feature.md Adds a release note for asset cache busting.

Reviews (6): Last reviewed commit: "Verify asset hashes with consecutive con..." | Re-trigger Greptile

Comment thread reflex/assets.py Outdated
Comment thread reflex/assets.py
@codspeed-hq

codspeed-hq Bot commented Jul 11, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 26 untouched benchmarks
⏩ 8 skipped benchmarks1


Comparing harsh21234i:fix/asset-content-hash-6550 (4f2e7b9) with main (32cc257)

Open in CodSpeed

Footnotes

  1. 8 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

Comment thread reflex/assets.py
Comment thread reflex/assets.py Outdated
Comment thread reflex/assets.py Outdated
Comment thread reflex/assets.py
Comment thread reflex/assets.py Outdated
Comment thread reflex/assets.py Outdated
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.

rx.asset: add content-hash cache-busting to returned URL

2 participants