Remove ineffective service worker fetch handler #2434
+0
−11
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.
This removes the fetch event listener that was added to address stale content when launching/resuming the PWA. I think the fix was ineffective for two reasons:
The service worker
fetchhandler only runs when an actual navigation occurs (cold start, manual refresh, link click). It does not run when a tab or PWA is resumed from memory, which is the primary scenario where users see stale content. When you switch back to a backgrounded tab, the page is already loaded in memory; no fetch happens.Even when a fetch does occur, the
cache: 'no-cache'option is redundant. The server already responds withCache-Control: max-age=0, private, must-revalidateheaders, which tells browsers to always revalidate before using cached HTML. The service worker was duplicating what the server headers already ensure.The actual stale content problem stems from
WebSocketdisconnection when tabs are backgrounded - Turbo Stream broadcasts are missed, and when the user returns, they see the in-memory page state from before. Solving this properly requires JavaScript that detects visibility changes and triggers a refresh after extended background time (similar to the existingframe_reloader_controllerpattern).