Skip to content

Conversation

bookernath
Copy link
Contributor

@bookernath bookernath commented Aug 13, 2025

What/Why?

As an optimization for the checkout loading speed, this PR adds an optimistic loading of the checkout redirect URL into the client side state at the time the cart page loads. If the user clicks the "checkout" button quickly (within a few seconds of loading the page), they will be redirected immediately, without the need to wait for roundtrip to generate the checkout redirect URL. In practice, this will save about ~500ms of latency on a desktop/strong connection, and perhaps more on mobile.

As the JWT expires after 30 seconds, client side code will compare the iat and eat against the client side time (with a best-effort attempt to account for skew) in order to decide if the JWT should be considered expired, in which case it will be re-generated and the user will be redirected as they were before this change - slower but reliable for this critically important navigation.

The net result is an improvement in load speed for shoppers who click "checkout" quickly, who are probably the most impatient ones anyways. :)

Todo:

  • Decide if this should be abstracted into a library instead of deploying this code directly in catalyst, and if it should be, abstract it

Testing

Preview deployment

Migration

Copy link

changeset-bot bot commented Aug 13, 2025

🦋 Changeset detected

Latest commit: e683bca

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

This PR includes changesets to release 1 package
Name Type
@bigcommerce/catalyst-core 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

Copy link

vercel bot commented Aug 13, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
catalyst-b2b Ready Ready Preview Comment Aug 23, 2025 10:03pm
catalyst-canary Ready Ready Preview Comment Aug 23, 2025 10:03pm
3 Skipped Deployments
Project Deployment Preview Comments Updated (UTC)
catalyst Ignored Ignored Aug 23, 2025 10:03pm
catalyst-au Ignored Ignored Aug 23, 2025 10:03pm
catalyst-uk Ignored Ignored Aug 23, 2025 10:03pm

@bookernath bookernath changed the title Use optimistic checkout redirect URL loading strategy to improve chec… Use optimistic checkout redirect URL loading strategy to improve checkout load time Aug 13, 2025
@bookernath bookernath force-pushed the optimistic-checkout-redirect-url branch from bca866a to 8858fe3 Compare August 13, 2025 22:38
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