We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Hi,
In some cases, it may be necessary to dynamically give the duration parameter.
something like this.
cache((req) => { if (req.mycondition) { return '1 minute'; } return '1 hour'; });
The text was updated successfully, but these errors were encountered:
i don't see why you couldn't use a function's output when setting the cache time
Sorry, something went wrong.
something like
const dynamicTime = () => { // ...criteria } app.use(cache( dynamicTime() )) // or with redis app.get('/will-be-cached', cacheWithRedis( dynamicTime() ), (req, res) => { res.json({ success: true }) })
Actually, what I want to say is:
I'm using a whole domain as a proxy, but I want to give different cache times for some paths.
const myProxy = createProxyMiddleware({ target: 'www.my-proxy-url.com' }); app.use(`/`, apicache.middleware('1 minute'), myProxy);
in this case i want to cache like this.
www.my-proxy-url.com/api/path1 ( 1 minute ) www.my-proxy-url.com/api/path2 ( 1 hour )
No branches or pull requests
Hi,
In some cases, it may be necessary to dynamically give the duration parameter.
something like this.
The text was updated successfully, but these errors were encountered: