fetch
doesn't cache when used in middleware
#51410
Unanswered
IonelLupu
asked this question in
App Router
Replies: 2 comments 7 replies
-
in the docs https://nextjs.org/docs/app/api-reference/functions/fetch#fetchurl-options they mention:
so I'm guessing this doesn't apply to middleware. |
Beta Was this translation helpful? Give feedback.
7 replies
-
Any updates on this? It seems cache is not available on the middleware |
Beta Was this translation helpful? Give feedback.
0 replies
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.
-
I created a middleware and inside it I called the API using the fetch function, just to test if the caching works. To my surprise, it didn't.
This is my setup:
And I get this in the console when I go to
http://localhost:3000/cache-test
and refresh the page even if I usecache: 'force-cache'
:Shouldn't I get
value -> { value: 1 }
every time?Beta Was this translation helpful? Give feedback.
All reactions