Keep the inbox fresh on back-navigation (turbo-cache-control)#3
Open
rameerez wants to merge 1 commit into
Open
Keep the inbox fresh on back-navigation (turbo-cache-control)#3rameerez wants to merge 1 commit into
rameerez wants to merge 1 commit into
Conversation
Companion to chats--refresh-inbox. That controller heals a MISSED live broadcast on a page that stays OPEN; it does nothing for the other inbox-staleness case: a Turbo RESTORATION visit (browser back / Hotwire Native stack pop) serves the inbox's cached snapshot with no GET. Open a chat from a profile, send a message, tap back — the snapshot cached before the chat existed returns and the new conversation is missing until you navigate away and return (pull-to-refresh is commonly disabled on the native inbox tab). `turbo-cache-control: no-cache` makes the inbox uncacheable, so a restore visit re-fetches from the network — fresh on web AND in Hotwire Native (back-pop issues a Turbo `.restore` visit that honors it; bundled turbo.js marks a no-cache page isCacheable=false, so restore falls through to a network fetch). Requires the host layout to `yield :head`; harmless no-op otherwise. The dummy layout now yields :head so the suite can assert it.
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.
Follow-up to #2. That PR added
chats--refresh-inbox, which heals a missed live broadcast on a page that stays open. This closes the other inbox-staleness case it can't touch.The gap
A Turbo restoration visit — browser back / Hotwire Native stack pop — serves the inbox's cached snapshot with no GET. Open a chat from a profile, send a message, tap back → the snapshot cached before the chat existed comes back and the new conversation is missing until you navigate away and return. Pull-to-refresh is commonly disabled on the native inbox tab, so there's no manual escape. (Reported + reproduced end-to-end in a downstream host app.)
The
chats--refresh-inboxcontroller can't help: it fires on cable reconnect / return-to-visible, not on a restore visit.Fix
turbo-cache-control: no-cacheon the inbox → Turbo never stores the snapshot → a restore visit re-fetches from the network and is always fresh.Verified it reaches Hotwire Native, not just web:
.restorevisit (Session.visitableViewWillAppear),no-cachepageisCacheable == false, so the restore visit finds no cached snapshot and falls through to a network fetch.Requires the host layout to
yield :head(the Rails convention); harmless no-op otherwise. The dummy layout now yields:headso the suite can assert the meta renders.Complementary to #2: missed live broadcast (controller) + stale restored snapshot (this). Both axes of inbox freshness now covered.