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

How to automatically clear redis route cache when building a new version? #85

Open
vuthanhbayit opened this issue Nov 19, 2024 · 1 comment

Comments

@vuthanhbayit
Copy link

Hello. After publishing a new version for the web, I want to automatically clear all route cache data on redis. Does anyone know how to do that?

@vuthanhbayit vuthanhbayit changed the title How to automatically clear redis route cache when building a new version How to automatically clear redis route cache when building a new version? Nov 19, 2024
@dulnan
Copy link
Owner

dulnan commented Nov 19, 2024

Yes, there are several approaches:

You can use the FLUSHALL command directly on redis, for example using redis-cli: https://redis.io/docs/latest/commands/flushall/

You can purge everything via this module's API:
https://nuxt-multi-cache.dulnan.net/features/api#purge-everything

Or you can implement the buildCacheKey method in the module's serverOptions: https://nuxt-multi-cache.dulnan.net/features/route-cache#cache-key-for-routes
This method is called to determine the key for the route cache item. You could add a version number or build/commit hash to this key that changes for every new version. By doing that you don't directly purge the cache. However you will make sure that after every deployment you won't be serving cached routes from before the deployment, since the key is now different.

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

No branches or pull requests

2 participants