-
-
Notifications
You must be signed in to change notification settings - Fork 498
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
Caching Problem (related to JS-SDK) #402
Comments
Thanks for opening a ticket with reproduction steps. This is more of a NextJS caching behavior, not an issue with the SDK itself. That being said, we need to make the entire caching story better, probably by first upgrading to NextJs 15, as they've done some changes to how caching works out of the box. We'll keep this ticket updated once we get this looked into. Also feel free to open a PR if you want to help with a fix |
Well we are using the SDK within Nextjs so we have to find a solution that makes it feasible to use it within Nextjs. Medusa has this article on their website, talking about benefits and also pointing out challenges (reading the article makes you think these challenges are solved):
But basically this starter doesn't live up to its promises because currently we have to disable the caching (simultaneously also removing benefits of Nextjs SSR) to use it. What would be a caching strategy moving forward? I understand the caching is caused by Nextjs extension of the fetch API and that is not the case when the Medusa SDK is used in another context. However, I think this should still be something that the SDK handles automatically, because this logic will be necessary in any implementation with Nextjs. Do you think we should move this issue to a different repository? If Nextjs is a common storefront technology, maybe a more specific SDK targeting Nextjs specific challenges could make more sense? One idea would be to subscribe/listen to changes from the medusa backend and purge the cache when necessary. Maybe a temporary solution could be to purge the complete cache with any change that is coming from the backend and in the future a more targeted approach? If I understand it correctly, I also found other inefficient ways how the cache is used:
or
This purges the cache for any user, would it not make more sense to have a more user specific cache and only purge the cache necessary? Temporarily, what would make sense to target? Disabling the caching completely till there is a more sophisticated cache handling solution? |
I am experiencing caching problems in various places, basically anywhere the JS-SDk is used.
But to reproduce here is a specific example.
The SDK is performing a request:
Adding no caching to the Medusa SDK init fixes the issue:
But also then removes the caching completely 😛
The text was updated successfully, but these errors were encountered: