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
-
Environment:
Operating System: Linux
Node Version: v20.15.0
Nuxt Version: 3.13.0
Package Manager: [email protected]
Reproduction
https://stackblitz.com/edit/nuxt-starter-kjhdkn?file=server%2Fapi%2Ftest.get.js
npm install
thennpm run dev
Context:
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=true
query 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?
Beta Was this translation helpful? Give feedback.
All reactions