Using shouldBypassCache, should it still return stale-while-revalidate headers?
#2714
Unanswered
kaitoqueiroz
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Environment:
Operating System: Linux
Node Version: v20.15.0
Nuxt Version: 3.13.0
Package Manager: pnpm@9.4.0
Reproduction
https://stackblitz.com/edit/nuxt-starter-kjhdkn?file=server%2Fapi%2Ftest.get.js
npm installthennpm run devContext:
I'm working on a feature that uses SWR to cache the API responses for a certain period and revalidate after the TTL.
When I switch pages, I make a request to the API, and I want the cache to be bypassed when I set the
preview=truequery parameter.The problem is that the browser caches the response regardless, and when the user navigates, it still serves cached data.
Response headers in the first request (uncached):

Code:
Is it possible to avoid the response being cached in the browser when the cache is bypassed? Using shouldBypassCache, should it still return stale-while-revalidate headers?
Could anyone help me with that, please?
All reactions