-
Notifications
You must be signed in to change notification settings - Fork 511
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
Disable swr behavior by default for cached functions #1950
Comments
I would highly suggest Use case example:
|
Thanks for the feedback dear @MickL indeed most of the unwanted scenarios are for API/Function calls for action which probably makes no sense with the SWR caching strategy to be enabled by default (but probably also not any caching strategy. it mainly needs to avoid running multiple times in parallel using a semaphore lock/variable). |
As a user of The twin-like similarity of |
@pi0 is there any way to disable the default SWR behavior? I've just adopted Nuxt3 and am baffled as to why my API calls are being cached, and have no clear path to getting around this issue. |
You can find what you need in the options for cachedEventHandler. |
Having SWR implicitly by default can have unexpected results especially since it will be also enabled for
definedCachedFunction
.One example of when it can go unexpected is that when both a route (via routeRules) and the internal utils it is depending on are using cache, it doubles the cache invalidation time (it happened for ungh few days ago too for example although was explicit flag bug it is an easy trap!)
On the other hand, having SWR for page level caching i belive is something essential for best rendering performances (non API routes). But i guess for this, we have
swr: true
route rule shortcut so it should not be something to worry.It is a breaking behavior change still, therefore I am thinking of considering either via a minor version with good enough merits/docs or consider for Nitro v3. Ideas welcome 👍🏼
The text was updated successfully, but these errors were encountered: