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

Add an option to force a cache refresh when defining a cached event handler #745

Closed
1 task done
yassilah opened this issue Dec 10, 2022 · 0 comments
Closed
1 task done
Labels
enhancement New feature or request

Comments

@yassilah
Copy link
Contributor

Describe the feature

I have tried to use the existing options to allow for refreshing a cached endpoint output but haven't really succeeded in doing so. I would suggest adding a simple refresh option to the existing ones to allow for forcing a given endpoint to refresh its original state and store it for future requests. Here's an example usage:

export default defineCachedEventHandler(event => {
  return Math.floor(Math.random() * 5)
}, {
  refresh: event => getQuery(event).refresh === 'true'
})

/api/foo => cache initial value

3

/api/foo?refresh=true => renew cache

4 

/api/foo => use latest cache

4

Additional information

  • Would you be willing to help implement this feature?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants