Respect Cache-Control
header for fetch data-cache
#53504
Replies: 2 comments
-
Beta Was this translation helpful? Give feedback.
-
I recently read the blog post for Next.js 15 RC and while the new caching heuristics are a step in the right direction, It still leaves me puzzled how Next.js could come to the conclusion that the cache instruction ought to be reversed. The Cache-Control header was introduced in 1999 and has received many updates and revisions since its introduction. What has remained constant since then is that the server has always instructed the client on how the response can be cached. Next.js reverses this basic assumption about HTTP cacheability and instead completely ignores how a server provides instructions on how a resource can be cached by the client and instead imposes its own heuristics. This of course leads to severe under or over caching. While the browser does have a mechanism for storing HTTP Responses manually, this is completely redundant if the server responds with a proper It seems sensible to me that Next.js could respect the Instead, Next.js simply ignores decades of existing software and charts its own path, one that makes little sense to this engineer who has been making websites since before the |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Goals
Non-Goals
No response
Background
A user making requests with the openai TS SDK had to do some backflips to force Next to not use the cache for requests:
openai/openai-node#182 (comment)
We have workarounds available, but at least for certain endpoints, I'd expect ~nobody would want to cache these endpoints; it'd be nice if the library could either disable this cache by default, or allow the user to do so easily (passing headers is often easier through another library than nonstandard requestinit options).
Proposal
I don't have specific proposals, but following https://developer.mozilla.org/en-US/docs/Web/HTTP/Caching more closely or at least respecting
Cache-Control: no-cache
would be great.Beta Was this translation helpful? Give feedback.
All reactions