Skip to content

Conversation

@tchak
Copy link
Owner

@tchak tchak commented Jan 17, 2025

turbo will aggressively cache pages when rendering and use the cache for history navigation. If used in combination with turbo rendering (you really should override turbo rendering with our implementation of morph), the new cache option will help.

the scenario is as follows:

  • A page is rendered with the react fragment
  • navigate with turbo to a new page
  • turbo caches the page with the fragment containing either react rendered html or it will be empty (depending on the moment)
  • navigate back by pressing the back button
  • the cached page is reapplied. When coldwired tries to render the react fragment the source of the fragment is pre-rendered html or an empty string instead of JSX

This patch will preserve the fragment JSX source and try to restore it based on dom ids (they will be preserved in turbo cache)

@changeset-bot
Copy link

changeset-bot bot commented Jan 17, 2025

🦋 Changeset detected

Latest commit: ec19d69

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@coldwired/react Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@tchak tchak force-pushed the add-fragment-cache branch from 70320cb to ec19d69 Compare February 27, 2025 11:33
@tchak tchak merged commit 371feb1 into main Feb 27, 2025
1 check passed
@tchak tchak deleted the add-fragment-cache branch February 27, 2025 11:48
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.

1 participant