Serving stale response from cache middleware #2506
Unanswered
alexgleason
asked this question in
Q&A
Replies: 2 comments 2 replies
-
This seems to fix it, but it's pretty dirty: updateCache();
+ await new Promise((resolve) => setTimeout(resolve, 0));
return stale; |
Beta Was this translation helpful? Give feedback.
0 replies
-
Hi @alexgleason Do you run it on Deno? I've tried the same code on Deno, but the error was not thrown. Or how about if (response && expired) {
const stale = response.clone()
await updateCache()
return stale
} |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm building a memory cache middleware, but I'm stuck on making it serve a stale response and then build the new response in the background. Is this possible?
When
updateCache()
is called, it throws an error:Is seems I'm unable to call the next controller after I've already returned a response.
Is there any way around this?
Beta Was this translation helpful? Give feedback.
All reactions