-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Omit search part of path when detecting if the route changed after downloading asset bundles #6707
Omit search part of path when detecting if the route changed after downloading asset bundles #6707
Conversation
…wnloading asset bundles Resolves remix-run#6703 Previous implementation used the pathname and search parts of a url to determine if route changed, which causes some conflict when CDNs / cache proxies are placed between the Remix app and the client. This change allows remix to reload the page if only the path changes. There may be some issues with how loaders are handled when configured behind a CDN, since Remix expects to trigger loaders when the search part of a url changes, but the total impact here is dependent on how a developer is configuring the network topology on top of a Remix server.
🦋 Changeset detectedLatest commit: 9c6cf2f The changes in this PR will be included in the next version bump. This PR includes changesets to release 18 packages
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 |
@yarbsemaj @brophdawg11 Please see the note in the description. I am concerned about the impact this might have on loaders which expect specific search params to function correctly. I'm also not 100% sure I understand your use case @yarbsemaj. Please confirm the issue is something like:
I suspect the better solution here might be to change your cdn cache policy to ignore search params in the url. |
This ends up causing an infinite reload cycle for urls without query params when I test it as a patch on top of Remix 1.18.0 in our project. Edit: The infinite reload was actually caused by the patch being correctly applied to |
@n8agrin Unfortunately this is not an option in our setup, and i imagine many other as well |
@yarbsemaj ok. I’m not a fan of this approach. Closing. @brophdawg11 is the expert here as far as I can tell. I’ll wait for @brophdawg11 to weigh in |
@yarbsemaj This is a bit ambiguous to me. Is the pathname-only comparion implemented in this PR not an option for your setup? Or were you referring to the solution suggested by @n8agrin above:
From the description of your issue in #6703 it sounds like the root cause of your issue is the inclusion of search params in the hydration check, and that only comparing pathnames would suffice? |
I'm going to re-open this since I do believe this is the right solution to avoid reloads when CDN's ignore certain search parameters. I confirmed with @BillBrower-Shopify that this fix resolves the issue they are seeing which is due to the CDN only respecting certain search params. While this is sort of a non-standard HTTP caching approach, I believe it's probably used pretty frequently. Since the underlying issue here is a mismatch in matched routes on the server and the client, and route matching only cares about the |
Thanks for weighing in @brophdawg11 |
@@ -230,7 +230,7 @@ describe("remix CLI", () => { | |||
await interactWithShell(proc, [ | |||
{ question: /Where.*create.*app/i, type: [projectDir, ENTER] }, | |||
{ question: /What type of app/i, answer: /basics/i }, | |||
{ question: /Where.*deploy/i, answer: /express/i }, | |||
{ question: /Where.*deploy/i, answer: /remix/i }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ignore this unit test fix - this was fixed in dev
and cherry-picked into main
and release-next
. This branch has the main
SHA since I merged main
in - but this code is already in release-next
so it's not actually changing anything.
@@ -335,7 +335,7 @@ async function handleDocumentRequestRR( | |||
...entryContext, | |||
staticHandlerContext: context, | |||
serverHandoffString: createServerHandoffString({ | |||
url: context.location.pathname + context.location.search, | |||
url: context.location.pathname, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Keeping the url
name in this handoff string since it's technically exposed to users via EntryContext.serverHandoffString
and window.__remixContext
so just in case anyone is accessing it.
@@ -335,7 +335,7 @@ async function handleDocumentRequestRR( | |||
...entryContext, | |||
staticHandlerContext: context, | |||
serverHandoffString: createServerHandoffString({ | |||
url: context.location.pathname + context.location.search, | |||
pathname: context.location.pathname, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we consider this handoff format public API? If so can we not re-name the property here and re-purpose the "url" name?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated in 9c6cf2f
🤖 Hello there, We just published version Thanks! |
🤖 Hello there, We just published version Thanks! |
Sorry for the confusion, i was referring to this comment about updating our CDN Policy, this is due to us needing access to a full range of query parameters on certan, arbitrary routes that can not easily be modeled with cache behaviours.
|
@yarbsemaj No worries! Can you confirm if |
🤖 Hello there, We just published version Thanks! |
🤖 Hello there, We just published version Thanks! |
Resolves #6703
Previous implementation used the pathname and search parts of a url to determine if route changed, which causes some conflict when CDNs / cache proxies are placed between the Remix app and the client. This change allows remix to reload the page if only the path changes. There may be some issues with how loaders are handled when configured behind a CDN, since Remix expects to trigger loaders when the search part of a url changes, but the total impact here is dependent on how a developer is configuring the network topology on top of a Remix server.
Closes: #6703
Testing Strategy: