Prerendering detection & handle differential versions #2567
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.
What/Why?
This pull request implements a prerendering staleness detection system for BigCommerce checkout pages
to improve user experience during navigation from prerendered pages.
Problem: When users navigate to checkout pages that were prerendered using the Speculation Rules API,
the prerendered data may become stale if the user modified their cart in another tab. This results
in users seeing outdated cart contents, totals, or checkout state.
Solution: Implements a comprehensive staleness detection system that:
response to detect when checkout data has changed
data when stale
Technical Implementation:
Additional Fixes:
Rollout/Rollback
Rollout: This change can be safely rolled out immediately as it:
Measuring Success:
Rollback: Simple code revert if needed. No database migrations or persistent state changes. The
feature is entirely client-side and self-contained.
Testing
Unit Tests: All 18 tests passing for the staleness detection system:
npx nx run core:test --testPathPattern=prerenderingStalenessDetector
✓ PrerenderingStalenessDetector (9 tests)
✓ createPrerenderingChangeHandler (3 tests)
✓ createCheckoutRefreshAPI (6 tests)
Integration Testing:
Manual Testing Approach:
Browser Compatibility: Feature uses progressive enhancement - falls back gracefully in browsers
without Speculation Rules API support.
Performance Impact: Minimal - only adds version comparison logic and event listener. No impact on
users without prerendering.