Skip to content
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

feat(resourcefactory): added dispose option to ResourceFactory.use #35

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jacob-ebey
Copy link

@jacob-ebey jacob-ebey commented Dec 29, 2020

This change allows for things like page transitions to not bust the cache and reload from there on
back button. Does not modify existing behavior.

This change allows for things like page transitions to not bust the cache and reload from there on
back button.
@overlookmotel
Copy link
Owner

Thanks for this.

Hmm. I understand the use case, but the problem I foresee is that the data will then never be disposed of. This has two problems I can think of:

  1. The cache would grow and consume memory with no limit.
  2. Once loaded, data can never be re-loaded, so stale data will stick around forever. They'd be no way to fetch fresh data without a hard reload (i.e. "Reload" button).

Do you have thoughts on how to counter either of these problems?

@jacob-ebey
Copy link
Author

jacob-ebey commented Jan 2, 2021

@overlookmotel I'll have to look into it further. For further context, here is the use-case I'd like to enable:

image

1.) Server SSR's and stores in CDN edge edge cache
2.) User transitions to page 2 client side and fetches data client side skipping SSR on the Server
3.) User client side transitions back to initial SSR'd page via back button (should not trigger client side fetch as data should persist in cache)

Here is an example of the current behavior: https://pwrc-react.vercel.app/examples/ecom-example/
(you may have to slow down network calls or something to visually see the issue, but you can see it in the network logs). This is really just chasing any performance gains that are left.

Initial SSR'd load of home page loading client only assets:
image

Transition to PDP page properly loads assets that would have been in SSR'd response client side:
image

Transition back to home page from PDP unnecessarily loading data available in SSR'd response (yellow is SSR'd data not fetched in initial page load):
image

@overlookmotel
Copy link
Owner

So is the idea that the data is static and never ever changes?

@jacob-ebey
Copy link
Author

@overlookmotel exactly. SSR'd data should remain static unless a manual invalidation action is taken.

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.

2 participants