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: implement dynamic cache tags #17

Merged
merged 2 commits into from
Sep 30, 2024
Merged

Conversation

VariableVic
Copy link
Collaborator

Implements dynamic cache tags throughout the storefront. This ensures that the cache will be invalidated for the current client only when server data mutates.

  • Added some logic to Nextjs middleware that generates a unique id and sets it in a _medusa_cache_id cookie.
  • Added a getCacheTag() helper function which takes in a string input. This will return a dynamic cache tag string in the format {input}-{_medusa_cache_id}. This is useful when revalidating tags after performing a mutation.
  • Added a getCacheHeaders() helper function which takes in a string input. This will return the next: {} headers to assign a dynamic cache tag to a GET request.

@VariableVic VariableVic merged commit d93f8a1 into main Sep 30, 2024
1 check passed
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